@algorithm.ts/sieve-prime
TypeScript icon, indicating that this package has built-in type declarations

2.0.14 • Public • Published

@algorithm.ts/sieve-prime


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]

Related

Package Sidebar

Install

npm i @algorithm.ts/sieve-prime

Weekly Downloads

7

Version

2.0.14

License

MIT

Unpacked Size

6.32 kB

Total Files

6

Last publish

Collaborators

  • lemonclown