Created
December 23, 2016 02:56
-
-
Save louisswarren/3a7472d97f346ab9527c2b4f716b486b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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