Skip to content

Instantly share code, notes, and snippets.

@Cosikowy
Created August 27, 2020 08:33
Show Gist options
  • Save Cosikowy/f87734596ae9bd5768b59ab4c00a7cf7 to your computer and use it in GitHub Desktop.
Save Cosikowy/f87734596ae9bd5768b59ab4c00a7cf7 to your computer and use it in GitHub Desktop.
def nats(s):
yield s
yield from nats(s+1)
def sieve(s):
n = next(s)
yield n
yield from sieve(i for i in s if i%n!=0)
prime = sieve(nats(2))
primes = []
for x in range(100):
primes.append(next(prime))
print(primes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment