Dec-18-2019, 06:41 AM
In Python wiki (under '20 lines: Prime numbers sieve w/fancy generators') there is much better example of implementation:
import itertools def iter_primes(): # An iterator of all numbers between 2 and # +infinity numbers = itertools.count(2) # Generate primes forever while True: # Get the first number from the iterator # (always a prime) prime = next(numbers) yield prime # This code iteratively builds up a chain # of filters... numbers = filter(prime.__rmod__, numbers) for p in iter_primes(): if p > 1000: break print(p)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.