Lets write the first 10000 primenumbers

There are 6,352 replies in this Thread. The last Post () by Mufica.

  • 34439


    Why noone made a mistake in this thread ?
    is everyone here simply too smart for that ? :P

    Chars: [CFPD]Michael~something (x25), [CFPD]~SQMS~{[(store)]} (x3), [CFPD]xfer, Event~Manager~Michael, StarfIier~EM~Michael, Event_Team_2, [GR]Michael[SP] and a blueprint of [CFPD]Sephirothis

  • 34471


    it's a way of self-cultivation, as Leo Tolstoy wrote :rolleyes:

  • 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 :P Huor made one as well. Very easy. )

    Chars: [CFPD]Michael~something (x25), [CFPD]~SQMS~{[(store)]} (x3), [CFPD]xfer, Event~Manager~Michael, StarfIier~EM~Michael, Event_Team_2, [GR]Michael[SP] and a blueprint of [CFPD]Sephirothis

  • 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 :huh:

  • 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 ^^

    Chars: [CFPD]Michael~something (x25), [CFPD]~SQMS~{[(store)]} (x3), [CFPD]xfer, Event~Manager~Michael, StarfIier~EM~Michael, Event_Team_2, [GR]Michael[SP] and a blueprint of [CFPD]Sephirothis

  • 34511


    yea, and here is the code I meant.


    It was made as executable, but the full source code is this:



    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.

    Chars: [CFPD]Michael~something (x25), [CFPD]~SQMS~{[(store)]} (x3), [CFPD]xfer, Event~Manager~Michael, StarfIier~EM~Michael, Event_Team_2, [GR]Michael[SP] and a blueprint of [CFPD]Sephirothis

  • 34513


    thanks a lot, this code is ready for being compiled into a console application :thumbup:
    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" :D


    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: Irony
    Seems you are already iniciated in the art of basic coding, shall you be my... nevermind, I have no time for training a padawan :P

    Chars: [CFPD]Michael~something (x25), [CFPD]~SQMS~{[(store)]} (x3), [CFPD]xfer, Event~Manager~Michael, StarfIier~EM~Michael, Event_Team_2, [GR]Michael[SP] and a blueprint of [CFPD]Sephirothis

  • well,

    Code
    1. cout<<"Which numbers you want to check ?"<<endl;cout<<"Write your first number:";cin>>n1;


    looks a little simpler than

    Code
    1. printf ("Which numbers you want to check ?");
    2. printf ("\nWrite your first number:");
    3. scanf ("%d", &n1);


    that's what I meant :) though it's a matter of habit indeed


    Attention: Irony
    but of course your word is final, master :( 

    34537

    Edited 2 times, last by Cresthen ().

  • 34543


    I never seen the need to add that <<endl; neither in this case. \n works with cout as well.

    Chars: [CFPD]Michael~something (x25), [CFPD]~SQMS~{[(store)]} (x3), [CFPD]xfer, Event~Manager~Michael, StarfIier~EM~Michael, Event_Team_2, [GR]Michael[SP] and a blueprint of [CFPD]Sephirothis

  • 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 :rtfm:

  • 34583 hmm, a lot of space here.


    easy to read, hmm, for me, the shorter, the better :D (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. :)

    Chars: [CFPD]Michael~something (x25), [CFPD]~SQMS~{[(store)]} (x3), [CFPD]xfer, Event~Manager~Michael, StarfIier~EM~Michael, Event_Team_2, [GR]Michael[SP] and a blueprint of [CFPD]Sephirothis