Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (24 sloc) 522 Bytes
# coding: utf-8
import math
def _is_prime(n, primes):
if n % 2 == 0 or n % 3 == 0:
return False
s = int(math.sqrt(n)) + 1
for p in primes:
if p > s:
break
if n % p == 0:
return False
return True
def prime_one(n):
primes = [2, 3, 5]
i = 7
step = 2
while i <= n:
if _is_prime(i, primes):
primes.append(i)
step = 6 - step
i += step
return primes
if __name__ == "__main__":
print(prime_one(200))
You can’t perform that action at this time.