Prime number test
Posted: Mon Jan 17, 2011 2:11 am
Alright. I am here to ask a question. I don't know if this belongs here or not.
I am using python and am on problem #10.
My program was going incredibly slow until I changed it from:
to:
I had seen that on other people's prime tests.
My question is: Why does this work?
I am using python and am on problem #10.
My program was going incredibly slow until I changed it from:
Code: Select all
for i in range(3, 2000000, 2):
for i in range(2, x, 2):
Code: Select all
for i in range(3, 2000000, 2):
for i in range(2, x**0.5+1, 2):
My question is: Why does this work?