Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

prime number question

Name: Anonymous 2007-07-05 10:14 ID:YoB+8Y1c

why is it that in many algorithms to test if a number is prime, using a brute force division, it only checks for divisors up to the square root of the number to be checked?

for example:

bool isprime(n){
for i from 2 to ceil(sqrt(n)){
if n%i==0: return false;}

return true;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List