import mathdef sieve(n): primes = [True]*n primes[0] = False primes[1] = False for i in range(2,int(math.sqrt(n))+1): j = i*i while j < n: primes[j] = False j = j+i return [x for x in range(n) if primes[x] == True]
↧
Answer by nhern121 for Sieve of Eratosthenes - Finding Primes Python
↧