User:Yeti: Difference between revisions

Content deleted Content added
Yeti (talk | contribs)
mNo edit summary
Yeti (talk | contribs)
Line 31: Line 31:
{{works with|Python|2.x}}
{{works with|Python|2.x}}
This is a sequentialised variant of the well known sieve method (ab)using a dictionary as sparse array.
This is a sequentialised variant of the well known sieve method (ab)using a dictionary as sparse array.

Alternatively you can describe it as finding the wheels and moving them on a tape. The only knowledge is to start looking 2 instead of starting with 1, but the original sieve does skip 1 too. 2 is not hard coded to be prime. The algorithm detects it as 1st prime and then puts the 2-wheel on the tape.

<lang python>L = {}
<lang python>L = {}
n = 2
n = 2