Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This uses trial division to find primes, which is not efficient, and I would not recommend using this implementation.

Instead you should use the Sieve of Eratosthenes algorithm. Unfortunately this algorithm is easier to implement in an imperative, eager fashion than in a lazy, functional fashion.

See the paper "The Genuine Sieve of Eratosthenes" for more details: https://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: