It means thats the running time for the program, if you compiled his code for 10000 and my code for 10000 my code is like a lot faster
Prime numbers
Oh, that's interesting. How did you figure that one out?
Ok you see lala's code:
Thats about 10000 runs which is n
Now inside that for loop is another for loop!
the average of all these runs is about n/2 (5000)
(sorry i was wrong it n*(n/2) not n sqaured)
Now my code:
thats about n/2 (5000) runs for each odd number
i check the prime list for any factors up to the square root of the number to check
that should be sqrt(n)/2 about the average
so my running time would be: n/2 * sqrt(n)/2 and lalas: n*(n/2)
Code:
for (prime = 1;prime <=10000; prime++)
Now inside that for loop is another for loop!
Code:
for (checker = 1; checker <prime; checker++)
(sorry i was wrong it n*(n/2) not n sqaured)
Now my code:
Code:
for(i=5;i<10000;i+=2)
Code:
for(i2=0,prime=true;primelist[i2]<=sqrt(i);i2++)
that should be sqrt(n)/2 about the average
so my running time would be: n/2 * sqrt(n)/2 and lalas: n*(n/2)
This thread is closed for replies.
