[Edu-sig] Kirby Urner's Sieve of Eratosthenes

Kirby Urner pdx4d@teleport.com
Mon, 05 Jun 2000 11:38:43 -0700


John Posner wrote:
>In my opinion, Kirby's implementation (see below) works too hard. The
>critical problem is that it uses an old-fashioned LOOP to do the work
>instead of using a nifty, Pythonic FILTER. After all, a SIEVE is just 
>a kind of FILTER.

I appreciate John's taking the time to explore an alternative
-- I hadn't really tuned in FILTER until now.

Note that my version, while not as compact in code, uses only 
addition to change 1s to 0s.  Using % over range(2,limit) 
implies many divisions, and perhaps is not as fast, though 
I haven't done any work to ascertain this for a fact.

Kirby