Learn To Solve It
Illustrate the sieve of eratosthenes method to find out prime numbers.
def eratosthenes(): D = {} q = 2 while True: p = D.pop(q, None) if p: x = p + q while x in D: x += p D[x] = p else: D[q*q] = q yield q q += 1
See also
Suggest a Code Improvement:algorithm_eratosthenes.py
Suggest a better explanation for algorithm_eratosthenes.rst
previous
Checking String Text Or Binary
next
Fibonacci Series