Skip to content

Instantly share code, notes, and snippets.

@KerryJones
Created December 31, 2015 07:53
Show Gist options
  • Select an option

  • Save KerryJones/c393280ad6e3782948d0 to your computer and use it in GitHub Desktop.

Select an option

Save KerryJones/c393280ad6e3782948d0 to your computer and use it in GitHub Desktop.
Sieve of Eratosthenes
def sieve_of_eratosthenes(max):
flags = [True] * max
flags[0] = flags[1] = False
for (i, isPrime) in enumerate(flags):
if isPrime:
print(i)
for n in range(i*i, max, i):
flags[n] = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment