1.3.3 • Published 4 years ago

primes-and-factors v1.3.3

Weekly downloads
30
License
MIT
Repository
github
Last release
4 years ago

primes-and-factors

Module with simple primality tester and functions to return prime factors of a number in various formats. Find module on npm and code repo with examples on GitHub.

API

const pf = require('primes-and-factors');
pf.isPrime(number);                // return boolean: true if number is prime (e.g. 5), false otherwise (e.g. 18)
pf.getFactors(number);             // get array of prime factors of a number (e.g. [2, 3, 3] for 18)
pf.getUniqueFactors(number);       // get array of distinct prime factors of a number (e.g. [2, 3] for 18)
pf.getPrimeExponentObject(number); // get object of primes and exponents (e.g. {2:1, 3:2} for 18)
pf.getFrequency(number);           // get array of objects, each object for a prime power factor p^k
                                   // with object format {factor: p, times: k}

Use npm i primes-and-factors to install. For full examples see GitHub examples directory. Works up to Number.MAX_SAFE_INTEGER which is approximately 9e15.

1.3.3

4 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.2

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.0

8 years ago

0.1.1

8 years ago