top | item 37238753

(no title)

anaphor | 2 years ago

There's a functional / lazy version I like that uses a priority queue in order to get the next prime number https://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf

It basically uses the priority queue to store all the composites up to a certain point and then you can assume the next one is prime.

I had some (admittedly not well written) code for it too https://gist.github.com/weskerfoot/4699275

It can also incorporates the wheel factorization optimization mentioned in this article.

discuss

order

No comments yet.