4.0.3 • Published 9 months ago
@algorithm.ts/prime v4.0.3
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.3
9 months ago
4.0.2
10 months ago
4.0.1
1 year ago
4.0.0
1 year ago
3.1.1
2 years ago
3.1.0
2 years ago
3.0.0-alpha.8
2 years ago
3.0.0
2 years ago
3.0.0-alpha.3
3 years ago
3.0.0-alpha.2
3 years ago
3.0.0-alpha.5
3 years ago
3.0.0-alpha.4
3 years ago
3.0.0-alpha.7
2 years ago
3.0.0-alpha.6
3 years ago
3.0.0-alpha.1
3 years ago
3.0.0-alpha.0
3 years ago