4.0.0 • Published 2 months ago

@algorithm.ts/prime v4.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

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/prime
  • yarn

    yarn add @algorithm.ts/prime

Usage

  • Get all prime numbers in the range $[2, N)$:

    import { sievePrime } from '@algorithm.ts/prime'
    
    sievePrime(5)   // => [2, 3]
    sievePrime(6)   // => [2, 3, 5]
    sievePrime(10)   // => [2, 3, 5, 7]
  • Get all prime numbers and totient function values in the range $[2, N)$:

    import { sieveTotient } from '@algorithm.ts/prime'
    
    const [totients, primes] = sieveTotient(10)
    // =>
    //    totients: [0, 1, 1, 2, 2, 4, 2, 6, 4, 6]
    //    primes: [2, 3, 5, 7]

Related

4.0.0

2 months ago

3.1.1

11 months ago

3.1.0

1 year ago

3.0.0-alpha.8

1 year ago

3.0.0

1 year ago

3.0.0-alpha.3

1 year ago

3.0.0-alpha.2

1 year ago

3.0.0-alpha.5

1 year ago

3.0.0-alpha.4

1 year ago

3.0.0-alpha.7

1 year ago

3.0.0-alpha.6

1 year ago

3.0.0-alpha.1

2 years ago

3.0.0-alpha.0

2 years ago