Skip to content

Instantly share code, notes, and snippets.

@nyango
nyango / prime.py
Last active July 17, 2016 10:06 — forked from graph226/prime.py
Sieve of Eratosthenes by Python
import math
NUMBER = 100000000
def get_prime_list(limit):
limit_sqrt = int(math.ceil(math.sqrt(limit)))
prime_bool_list = [False] * 2 + [True] * (limit - 2)
for prime_cand in xrange(2,limit_sqrt):
if prime_bool_list[prime_cand]:
for composite in range(prime_cand ** 2, limit, prime_cand):
prime_bool_list[composite] = False