Ok you see lala's code:
Code:
for (prime = 1;prime <=10000; prime++)
Thats about 10000 runs which is n
Now inside that for loop is another for loop!
Code:
for (checker = 1; checker <prime; checker++)
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:
Code:
for(i=5;i<10000;i+=2)
thats about n/2 (5000) runs for each odd number
Code:
for(i2=0,prime=true;primelist[i2]<=sqrt(i);i2++)
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)