0.0.0 • Published 4 years ago

prime-number-sequence v0.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

sieve-of-eratosthenes

description

Find all prime numbers in a sequence from 2..n using the Sieve of Eratosthenes algorithm:

example

let sieve = require('prime-number-sequence');


// returns [2, 3, 5, 7]
// throws Error if n < 2 or n is not a whole number
let primeNumbers = sieve.primeNumbersUpToN(9);

Sieve of Eratosthenes algorithm: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes#:~:text=In%20mathematics%2C%20the%20sieve%20of,the%20first%20prime%20number%2C%202.(https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes#:~:text=In mathematics%2C the sieve of,the first prime number%2C 2.)