Skip to content

Instantly share code, notes, and snippets.

View st1vms's full-sized avatar
😎

Stefano Raneri st1vms

😎
View GitHub Profile
@st1vms
st1vms / sieve_atkin.py
Last active September 9, 2023 12:57 — forked from mineta/marinamele_sieve_atkin.py
Python code implementing Sieve of Atkin algorithm for getting list of primes up to limit.
import math
def atkin(nmax:int) -> list[int]:
"""
Returns a list of prime numbers below the number `nmax`
"""
is_prime = dict([(i, False) for i in range(5, nmax+1)])
for x in range(1, int(math.sqrt(nmax))+1):
for y in range(1, int(math.sqrt(nmax))+1):
n = 4*x**2 + y**2