Skip to content

Instantly share code, notes, and snippets.

@ssanin82
Created February 10, 2015 04:14
Show Gist options
  • Save ssanin82/09214d2216a79e87f09a to your computer and use it in GitHub Desktop.
Save ssanin82/09214d2216a79e87f09a to your computer and use it in GitHub Desktop.
def get_primes_under(n):
primes = list()
sieve = [0] * (n + 1)
for i in xrange(2, n):
if not sieve[i]:
primes.append(i)
for j in xrange(i + i, n, i):
sieve[j] = 1
return primes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment