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

2.0.14 • Public • Published

@algorithm.ts/sieve-totient


A typescript implementation of the Linear Sieve algorithm for primes numbers and Euler's totient function.

If you are curious about this algorithm, you can visit here for more details.

Install

  • npm

    npm install --save @algorithm.ts/sieve-totient
  • yarn

    yarn add @algorithm.ts/sieve-totient
  • deno

    import sieveTotient from 'https://raw.githubusercontent.com/guanghechen/algorithm.ts/main/packages/sieve-totient/src/index.ts'

Usage

  • Get all prime numbers and totient function values in the range $[2, N)$:

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

Related

/@algorithm.ts/sieve-totient/

    Package Sidebar

    Install

    npm i @algorithm.ts/sieve-totient

    Weekly Downloads

    15

    Version

    2.0.14

    License

    MIT

    Unpacked Size

    7.17 kB

    Total Files

    6

    Last publish

    Collaborators

    • lemonclown