antiprime
Because sometimes we want highly composite numbers.
Installation
npm i --save antiprime
Usage
JavaScript
const isHighlyComposite = ;const hc = ;console; //Outputs: true
TypeScript
;;console.logap.isAntiprime; //Outputs: false
API
n;n; //alias
Creates a new Antiprime class object.
Properties
value
The positive integer value currently stored in the Antiprime object.
Functions
//alias
Returns a new Antiprime
object where value
is equal to the next lowest Antiprime number.
//alias
Returns a new Antiprime
object where value
is equal to the next largest Antiprime number.
Returns an array of numbers that include all factors including the 1 and value
.
Returns an array of objects with properties factor
and exponent
of all prime factors.
As well as the Antiprime
class, there are exported functions that can used to test numbers without calculating other properties.
Functions
Takes an input integer n
and returns all factors of the input as an array of numbers.
//alias
Takes an input integer n
and returns true
if the input is highly composite; false otherwise. Optional input pf
is the output to the primeFactors
function. This is provided to reduce computational overhead in the case that primeFactors
has been calculated for n
previously.
Takes an input integer n
and returns true
if the input is a candidate for a highly composite number; false otherwise. Optional input pf
is the output to the primeFactors
function. This is provided to reduce computational overhead in the case that primeFactors
has been calculated for n
previously.
A candidate is a number that meets the following criteria:
- The
k
prime factors are equal to the firstk
prime numbers. - The exponent of each prime factor does not increase as the magnitude of prime factors increases.
- The exponent of the final prime factor is
1
. n
is one of the special cases: 4 or 36.
Takes the output of primeFactors
and returns true
if the k
prime factors are equal to the first k
prime numbers; false
otherwise.
Returns true if the input number n
is prime; false
otherwise.
Takes the output of primeFactors
and returns true
if the exponent of each prime factor does not increase as the magnitude of prime factors increases; false
otherwise.
Returns the next prime number larger than the magnitude of n
.
Returns an array of objects containing the properties factor
and magnitude
representing the prime factors of n
and their magnitude.
Test
npm run test