@algorithm.ts/sieve-prime
v2.0.14
Published
A linear time algorithm to sieve prime numbers
Downloads
62
Maintainers
Readme
A typescript implementation of the Linear Sieve algorithm for prime numbers.
If you are curious about this algorithm, you can visit here for more details.
Install
npm
npm install --save @algorithm.ts/sieve-prime
yarn
yarn add @algorithm.ts/sieve-prime
deno
import sievePrime from 'https://raw.githubusercontent.com/guanghechen/algorithm.ts/main/packages/sieve-prime/src/index.ts'
Usage
Get all prime numbers in the range $[2, N)$:
import sievePrime from '@algorithm.ts/sieve-prime' sievePrime(5) // => [2, 3] sievePrime(6) // => [2, 3, 5] sievePrime(10) // => [2, 3, 5, 7]