Skip to content

Instantly share code, notes, and snippets.

View pabloferz's full-sized avatar

Pablo Zubieta pabloferz

View GitHub Profile
#==============================================================================#
# Optimized Sieve of Atkin
#==============================================================================#
function atkin(n::Int)
s = zeros(Bool, n < 2 ? 0 : n)
n < 2 && return s; s[2] = true
n < 3 && return s; s[3] = true
for x = 1:floor(Int,sqrt(n/4))
j = 4 * x * x