#!/usr/bin/python import itertools; def PrimeGen(): for p in itertools.count(2): if (reduce(lambda a,b: a and b, map(lambda i: p % i != 0, range(2,p)),True)): yield p for p in PrimeGen(): if (p < 100): print p else: break
Click here to download c24/primes.py
.
#!/usr/bin/python import itertools; def PrimeGen(): for p in itertools.count(2): if (reduce(lambda a,b: a and b, map(lambda i: p % i != 0, range(2,p)),True)): yield p for p in PrimeGen(): if (p < 100): print p else: break