Skip to content

Instantly share code, notes, and snippets.

@wmmnola
Last active June 15, 2020 16:26
Show Gist options
  • Save wmmnola/ec6a8b6fa57a66cb03d2c67f3682f1a7 to your computer and use it in GitHub Desktop.
Save wmmnola/ec6a8b6fa57a66cb03d2c67f3682f1a7 to your computer and use it in GitHub Desktop.
A function which generates finds the primes up to a given n
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