<s>
In	O
mathematics	O
,	O
the	O
sieve	B-Algorithm
of	I-Algorithm
Atkin	I-Algorithm
is	O
a	O
modern	O
algorithm	O
for	O
finding	O
all	O
prime	O
numbers	O
up	O
to	O
a	O
specified	O
integer	O
.	O
</s>
<s>
Compared	O
with	O
the	O
ancient	O
sieve	B-Algorithm
of	I-Algorithm
Eratosthenes	I-Algorithm
,	O
which	O
marks	O
off	O
multiples	O
of	O
primes	O
,	O
the	O
sieve	B-Algorithm
of	I-Algorithm
Atkin	I-Algorithm
does	O
some	O
preliminary	O
work	O
and	O
then	O
marks	O
off	O
multiples	O
of	O
squares	O
of	O
primes	O
,	O
thus	O
achieving	O
a	O
better	O
theoretical	O
asymptotic	O
complexity	O
.	O
</s>
<s>
The	O
following	O
is	O
pseudocode	B-Language
which	O
combines	O
Atkin	O
's	O
algorithms	O
3.1	O
,	O
3.2	O
,	O
and	O
3.3	O
by	O
using	O
a	O
combined	O
set	O
"	O
s	O
"	O
of	O
all	O
the	O
numbers	O
modulo	O
60	O
excluding	O
those	O
which	O
are	O
multiples	O
of	O
the	O
prime	O
numbers	O
2	O
,	O
3	O
,	O
and	O
5	O
,	O
as	O
per	O
the	O
algorithms	O
,	O
for	O
a	O
straightforward	O
version	O
of	O
the	O
algorithm	O
that	O
supports	O
optional	O
bit	O
packing	O
of	O
the	O
wheel	O
;	O
although	O
not	O
specifically	O
mentioned	O
in	O
the	O
referenced	O
paper	O
,	O
this	O
pseudocode	B-Language
eliminates	O
some	O
obvious	O
combinations	O
of	O
odd/even	O
y	O
's	O
in	O
order	O
to	O
reduce	O
computation	O
where	O
those	O
computations	O
would	O
never	O
pass	O
the	O
modulo	O
tests	O
anyway	O
(	O
i.e.	O
</s>
<s>
This	O
pseudocode	B-Language
is	O
written	O
for	O
clarity	O
;	O
although	O
some	O
redundant	O
computations	O
have	O
been	O
eliminated	O
by	O
controlling	O
the	O
odd/even	O
x/y	O
combinations	O
,	O
it	O
still	O
wastes	O
almost	O
half	O
of	O
its	O
quadratic	O
computations	O
on	O
non-productive	O
loops	O
that	O
do	O
n't	O
pass	O
the	O
modulo	O
tests	O
such	O
that	O
it	O
will	O
not	O
be	O
faster	O
than	O
an	O
equivalent	O
wheel	B-Algorithm
factorized	I-Algorithm
(	O
2/3/5	O
)	O
sieve	B-Algorithm
of	I-Algorithm
Eratosthenes	I-Algorithm
.	O
</s>
<s>
This	O
is	O
slightly	O
better	O
performance	O
with	O
the	O
same	O
memory	O
requirement	O
as	O
the	O
page	O
segmented	O
sieve	B-Algorithm
of	I-Algorithm
Eratosthenes	I-Algorithm
which	O
uses	O
O(N loglogN )	O
operations	O
and	O
the	O
same	O
O( 	O
N1/2/logN	O
)	O
bits	O
of	O
memory	O
plus	O
a	O
minimal	O
page	O
buffer	O
.	O
</s>
<s>
However	O
,	O
such	O
a	O
sieve	O
does	O
not	O
outperform	O
a	O
Sieve	B-Algorithm
of	I-Algorithm
Eratosthenes	I-Algorithm
with	O
maximum	O
practical	O
wheel	B-Algorithm
factorization	I-Algorithm
(	O
a	O
combination	O
of	O
a	O
2/3/5/7	O
sieving	O
wheel	O
and	O
pre-culling	O
composites	O
in	O
the	O
segment	O
page	O
buffers	O
using	O
a	O
2/3/5/7/11/13/17/19	O
pattern	O
)	O
,	O
which	O
although	O
it	O
has	O
slightly	O
more	O
operations	O
than	O
the	O
Sieve	B-Algorithm
of	I-Algorithm
Atkin	I-Algorithm
for	O
very	O
large	O
but	O
practical	O
ranges	O
,	O
has	O
a	O
constant	O
factor	O
of	O
less	O
complexity	O
per	O
operation	O
by	O
about	O
three	O
times	O
in	O
comparing	O
the	O
per	O
operation	O
time	O
between	O
the	O
algorithms	O
implemented	O
by	O
Bernstein	O
in	O
CPU	O
clock	O
cycles	O
per	O
operation	O
.	O
</s>
<s>
The	O
main	O
problem	O
with	O
the	O
Page	O
Segmented	O
Sieve	B-Algorithm
of	I-Algorithm
Atkin	I-Algorithm
is	O
the	O
difficulty	O
in	O
implementing	O
the	O
"	O
prime	O
square	O
free	O
"	O
culling	O
sequences	O
due	O
to	O
the	O
span	O
between	O
culls	O
rapidly	O
growing	O
far	O
beyond	O
the	O
page	O
buffer	O
span	O
;	O
the	O
time	O
expended	O
for	O
this	O
operation	O
in	O
Bernstein	O
's	O
implementation	O
rapidly	O
grows	O
to	O
many	O
times	O
the	O
time	O
expended	O
in	O
the	O
actual	O
quadratic	O
equation	O
calculations	O
,	O
meaning	O
that	O
the	O
linear	O
complexity	O
of	O
the	O
part	O
that	O
would	O
otherwise	O
be	O
quite	O
negligible	O
becomes	O
a	O
major	O
consumer	O
of	O
execution	O
time	O
.	O
</s>
<s>
Thus	O
,	O
even	O
though	O
an	O
optimized	O
implementation	O
may	O
again	O
settle	O
to	O
a	O
O(n )	O
time	O
complexity	O
,	O
this	O
constant	O
factor	O
of	O
increased	O
time	O
per	O
operations	O
means	O
that	O
the	O
Sieve	B-Algorithm
of	I-Algorithm
Atkin	I-Algorithm
is	O
slower	O
.	O
</s>
<s>
A	O
special	O
modified	O
"	O
enumerating	O
lattice	O
points	O
"	O
variation	O
of	O
the	O
Sieve	B-Algorithm
of	I-Algorithm
Atkin	I-Algorithm
can	O
theoretically	O
compute	O
primes	O
up	O
to	O
N	O
using	O
O( 	O
N/loglogN	O
)	O
operations	O
with	O
N1/2	O
+	O
o(1 )	O
bits	O
of	O
memory	O
but	O
this	O
variation	O
is	O
rarely	O
implemented	O
.	O
</s>
<s>
That	O
is	O
a	O
little	O
better	O
in	O
performance	O
at	O
a	O
very	O
high	O
cost	O
in	O
memory	O
as	O
compared	O
to	O
both	O
the	O
ordinary	O
page	O
segmented	O
version	O
and	O
to	O
an	O
equivalent	O
but	O
rarely-implemented	O
version	O
of	O
the	B-Algorithm
sieve	I-Algorithm
of	I-Algorithm
Eratosthenes	I-Algorithm
which	O
uses	O
O(N )	O
operations	O
and	O
O( 	O
N1/2	O
( loglogN	O
)	O
/logN	O
)	O
bits	O
of	O
memory	O
.	O
</s>
