Created
December 31, 2015 07:53
-
-
Save KerryJones/c393280ad6e3782948d0 to your computer and use it in GitHub Desktop.
Sieve of Eratosthenes
This file contains hidden or 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 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