[Tutor] Prime numbers
yd
ydmt923 at gmail.com
Sat Mar 27 23:08:54 CET 2010
Having a problem finding the first 1000 prime numbers, here is my code:-
print(2)
n =3
counter =1
while counter <=1000:
for x in range(3,int((n**0.5)),2):
if n%x != 0:
print(n)
n+=1
counter+=1
else:
n+=1
The problem is, it prints 2 and then does nothing, yet if i try and close,
it says program is still running do you want to kill it, is there a way to
do this with lists, i know python has a prime function but i am not going to
use it because i want to solve this problem without 'cheating'.Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100327/424ba256/attachment.html>
More information about the Tutor
mailing list