Skip to content

Instantly share code, notes, and snippets.

@mvallebr
Forked from juanplopes/prime_factors.py
Created June 6, 2017 09:39
Show Gist options
  • Save mvallebr/c2a14e10d844c21db57dbed51a5cac82 to your computer and use it in GitHub Desktop.
Save mvallebr/c2a14e10d844c21db57dbed51a5cac82 to your computer and use it in GitHub Desktop.
def primes_up_to(N):
sieve = N*[True]
for i in range(2, N):
if not sieve[i]: continue
yield i
for j in range(i*i, N, i):
sieve[j] = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment