Skip to content

Instantly share code, notes, and snippets.

@louisswarren
Created December 23, 2016 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save louisswarren/3a7472d97f346ab9527c2b4f716b486b to your computer and use it in GitHub Desktop.
Save louisswarren/3a7472d97f346ab9527c2b4f716b486b to your computer and use it in GitHub Desktop.
def is_prime(n):
return all(n % i != 0 for i in range(2, 1 + int(n**0.5)))
def get_primes():
n = 2
while True:
if is_prime(n):
yield n
n += 1
def all_primes(limit):
for prime in get_primes():
if prime > limit:
return
print(prime)
all_primes(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment