thaw-sieve-of-eratosthenes
v0.0.1
Published
The Sieve of Eratosthenes (an ancient Greek prime number generator) as a JavaScript library
Downloads
5
Maintainers
Readme
thaw-sieve-of-eratosthenes
A JavaScript implementation of the Sieve of Eratosthenes, an ancient Greek prime number generator.
Most of this project's infrastructure was stolen from Jason Mulligan's (avoidwork's) tiny-graph project.
Installation
To install the stable version:
npm install --save thaw-sieve-of-eratosthenes
Example
const engine = require('thaw-sieve-of-eratosthenes');
console.log(engine.sieve(20)); // [2, 3, 5, 7, 11, 13, 17, 19]
console.log(engine.factorize(72)); // [2, 2, 2, 3, 3]
API
factorize(n)
Returns the unique prime factorization of n
as a list of integers
sieve(n)
Returns the list of all prime numbers less than n