Created
October 19, 2015 19:48
-
-
Save bee-san/479d9483807f893c786f to your computer and use it in GitHub Desktop.
Sieve of Era*
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 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