Last active
June 15, 2020 16:26
-
-
Save wmmnola/ec6a8b6fa57a66cb03d2c67f3682f1a7 to your computer and use it in GitHub Desktop.
A function which generates finds the primes up to a given n
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 erasto(n): | |
primes = [True] * n | |
sq = int(math.floor(math.sqrt(n))) | |
for i in range(2,sq): | |
j = i**2 | |
while j < n: | |
primes[j] = False | |
j += i | |
return primes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment