|Do you know where your variables are?|
Re: Sieve of Eratosthenes with closuresby djWestTexas (Initiate)
|on May 15, 2018 at 19:09 UTC||Need Help??|
I know that this is a very old thread, but I just ran across it today while researching Sieve of Eratosthenes implementations. I am awed by the great programming, but much of it is beyond me. However, my main interest was to find a great SoE implementation for use and examples to others. I was really interested in outright performance. With this qualifier in mind, here are a few observations:
The fastest implementation was the c code by AnonymousMonk. However, it isn't perl and has memory limitations for finding larger primes. But it is blazing fast for small lists of primes - 1st two million primes found in less than 1 second.
The fastest perl implementation was the code by tilly. It found all primes up to 2,000,003 in 1 second. It also scaled nearly linearly for up to 32 million primes (the last one I tested). Wow!
The original code by thinker was good. It found all primes up to 2,000,003 in 10 seconds. It didn't scale as well for larger values of primes.
The code by merlynn has some kind of problem. It took it 43 seconds to find all primes up to 2,000,003 and didn't scale well at all for larger values.
Hope my "years late" comment doesn't upset anyone's apple cart. But if anyone else, like me, runs across this thread, it may offer something useful.
If I need to find a bunch of primes quickly, I would use tilly's code!