Simple Prime Generator in Python
Posted
by marc lincoln
on Stack Overflow
See other posts from Stack Overflow
or by marc lincoln
Published on 2009-02-19T21:22:24Z
Indexed on
2010/04/12
18:33 UTC
Read the original article
Hit count: 518
Hi, could someone please tell me what I'm doing wrong with this code. It is just printing 'count' anyway. I just want a very simple prime generator (nothing fancy). Thanks a lot. lincoln.
import math
def main():
count = 3
one = 1
while one == 1:
for x in range(2, int(math.sqrt(count) + 1)):
if count % x == 0:
continue
if count % x != 0:
print count
count += 1
© Stack Overflow or respective owner