Skip to content

Instantly share code, notes, and snippets.

@bee-san
Created October 19, 2015 19:48
Show Gist options
  • Save bee-san/479d9483807f893c786f to your computer and use it in GitHub Desktop.
Save bee-san/479d9483807f893c786f to your computer and use it in GitHub Desktop.
Sieve of Era*
def eratosthenes(n):
all = []
prime = 1
print("1, 2,")
i = 3
while (i <= n):
if i not in all:
print(i, ",")
prime += 1
j = i
while (j <= (n / i)):
all.append(i * j)
j += 1
i += 2
print("\n")
eratosthenes(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment