34369
Lets write the first 10000 primenumbers
- endymion
- Thread is marked as Resolved.
-
-
34381
-
34403
-
34421
-
34429
-
34439
Why noone made a mistake in this thread ?
is everyone here simply too smart for that ?
-
34457
no, the thread is too simple even for us dummies

-
34469
underestimating ourselves as usual, huh ?
-
34471
it's a way of self-cultivation, as Leo Tolstoy wrote

-
34483
I had to recalculate it as I forgot it from high school >_> meh, 0.1 miliseconds with my self made prime numbers calculator tool(actually, everything except this last part was a joke
Huor made one as well. Very easy. ) -
34487
0.1 ms is a great result considering that there are no exact formulas capable of outputting the whole list of primenumbers, though it's easy to check whether a particular number is prime or not
I wish I could see the source code of your calculator
-
34499
There are, a simple formula which asks you for 2 numbers, and he calculates everything inside.
I'm not at my home's PC now, so I'll post the code later

But it's easier googling or checking the full list to 10 000th I posted on this thread, before

-
-
34511
yea, and here is the code I meant.
It was made as executable, but the full source code is this:
Display MoreC- #include <stdio.h>
- #include <conio.h>
- int main(void) {
- int n1, n2, f, sw, i, j;
- printf ("Which numbers you want to check ?");
- printf ("\nWrite your first number:");
- scanf ("%d", &n1);
- printf ("\nWrite your second number:");
- scanf ("%d", &n2);
- f=1;
- sw=0;
- printf ("\n\n Here are the primary numbers between the 2 numbers:");
- for(i=n1;i<n2;i=i+1){
- sw=0;
- for(j=2;j<i;j=j+1){
- if(i%j==0) sw=1;
- }
- if(sw==0) printf (" %d", i);
- }
- printf ("\n\nPress any button to continue");
- getch();
- return(0);
- }
The formula, the only thing that matters are the 2 "for"s, and the math part, the "i%j==0". The rest is just to make it work.
Instead of scanf and printf, there's also "cout" and "cin", depending on which ppl know.
-
34513
thanks a lot, this code is ready for being compiled into a console application
and yeah, adding "using namespace std" in the preprocessing section would allow to use cin and cout, which are a bit easier to deal with -
Yeah, that's why the "full source code"

They are not easier to use in a 2 lines code, I have to add 1 (the std) just to make them work, then splitting the cin/cout in parts for each character

34519
Attention: IronySeems you are already iniciated in the art of basic coding, shall you be my... nevermind, I have no time for training a padawan
-
well,
looks a little simpler than
that's what I meant
though it's a matter of habit indeed
Attention: Ironybut of course your word is final, master
34537 -
34543
I never seen the need to add that <<endl; neither in this case. \n works with cout as well.
-
34549
there's no functional difference, I just tried to make it look simpler, so that the the text in the quotes would be separated from the code
I was always told that the programmes must be easy to read
-
34583 hmm, a lot of space here.
easy to read, hmm, for me, the shorter, the better
(and I think the PC/machine appreaciates it as well, a toy for making some numbers not, but when playing with MBytes of this...) But apparently, not always, as printf is larger, but easier to understand, "print formula".so it's up to each one how he likes it.
