:
:
Prime Generator Python - .

2, 3, 5, 7 11. - .
def genprimes(limit):
D = {}
q = 2
while q <= limit:
if q not in D:
yield q
D[q * q] = [q]
else:
for p in D[q]:
D.setdefault(p + q, []).append(p)
del D[q]
q += 1
p = genprimes(100)
prms = [i for i in p]
print prms
:
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]