<s>
In	O
mathematics	O
,	O
the	O
sieve	B-Algorithm
of	I-Algorithm
Sundaram	I-Algorithm
is	O
a	O
variant	O
of	O
the	B-Algorithm
sieve	I-Algorithm
of	I-Algorithm
Eratosthenes	I-Algorithm
,	O
a	O
simple	O
deterministic	B-General_Concept
algorithm	I-General_Concept
for	O
finding	O
all	O
the	O
prime	O
numbers	O
up	O
to	O
a	O
specified	O
integer	O
.	O
</s>
<s>
The	O
sieve	B-Algorithm
of	I-Algorithm
Sundaram	I-Algorithm
sieves	O
out	O
the	O
composite	O
numbers	O
just	O
as	O
the	B-Algorithm
sieve	I-Algorithm
of	I-Algorithm
Eratosthenes	I-Algorithm
does	O
,	O
but	O
even	O
numbers	O
are	O
not	O
considered	O
;	O
the	O
work	O
of	O
"	O
crossing	O
out	O
"	O
the	O
multiples	O
of2	O
is	O
done	O
by	O
the	O
final	O
double-and-increment	O
step	O
.	O
</s>
<s>
The	O
above	O
obscure	O
but	O
as	O
commonly	O
implemented	O
Python	O
version	O
of	O
the	O
Sieve	B-Algorithm
of	I-Algorithm
Sundaram	I-Algorithm
hides	O
the	O
true	O
complexity	O
of	O
the	O
algorithm	O
due	O
to	O
the	O
following	O
reasons	O
:	O
</s>
<s>
The	O
inner	O
culling	O
loop	O
(	O
the	O
j	O
loop	O
)	O
exactly	O
reflects	O
the	O
way	O
the	O
algorithm	O
is	O
formulated	O
,	O
but	O
seemingly	O
without	O
realizing	O
that	O
the	O
indexed	O
culling	O
starts	O
at	O
exactly	O
the	O
index	O
representing	O
the	O
square	O
of	O
the	O
base	O
odd	O
number	O
and	O
that	O
the	O
indexing	O
using	O
multiplication	O
can	O
much	O
more	O
easily	O
be	O
expressed	O
as	O
a	O
simple	O
repeated	O
addition	O
of	O
the	O
base	O
odd	O
number	O
across	O
the	O
range	O
;	O
in	O
fact	O
,	O
this	O
method	O
of	O
adding	O
a	O
constant	O
value	O
across	O
the	O
culling	O
range	O
is	O
exactly	O
how	O
the	B-Algorithm
Sieve	I-Algorithm
of	I-Algorithm
Eratosthenes	I-Algorithm
culling	O
is	O
generally	O
implemented	O
.	O
</s>
<s>
Note	O
the	O
commented	O
out	O
line	O
which	O
is	O
all	O
that	O
is	O
necessary	O
to	O
convert	O
the	O
Sieve	B-Algorithm
of	I-Algorithm
Sundaram	I-Algorithm
to	O
the	O
Odds-Only	O
(	O
wheel	O
factorized	O
by	O
the	O
only	O
even	O
prime	O
of	O
two	O
)	O
Sieve	B-Algorithm
of	I-Algorithm
Eratosthenes	I-Algorithm
;	O
this	O
clarifies	O
that	O
the	O
only	O
difference	O
between	O
these	O
two	O
algorithms	O
is	O
that	O
the	O
Sieve	B-Algorithm
of	I-Algorithm
Sundaram	I-Algorithm
culls	O
composite	O
numbers	O
using	O
all	O
odd	O
numbers	O
as	O
the	O
base	O
values	O
,	O
whereas	O
the	O
Odds-Only	O
Sieve	B-Algorithm
of	I-Algorithm
Eratosthenes	I-Algorithm
uses	O
only	O
the	O
odd	O
primes	O
as	O
base	O
values	O
,	O
with	O
both	O
ranges	O
of	O
base	O
values	O
bounded	O
to	O
the	O
square	O
root	O
of	O
the	O
range	O
.	O
</s>
<s>
When	O
run	O
for	O
various	O
ranges	O
,	O
it	O
is	O
immediately	O
clear	O
that	O
while	O
,	O
of	O
course	O
,	O
the	O
resulting	O
count	O
of	O
primes	O
for	O
a	O
given	O
range	O
is	O
identical	O
between	O
the	O
two	O
algorithms	O
,	O
the	O
number	O
of	O
culling	O
operations	O
is	O
much	O
higher	O
for	O
the	O
Sieve	B-Algorithm
of	I-Algorithm
Sundaram	I-Algorithm
and	O
also	O
grows	O
much	O
more	O
quickly	O
with	O
increasing	O
range	O
.	O
</s>
