antiprime v1.0.6
antiprime
Because sometimes we want highly composite numbers.
Installation
npm i --save antiprimeUsage
JavaScript
const { isHighlyComposite } = require('antiprime');
const hc = isHighlyComposite(12);
console.log(hc); //Outputs: trueTypeScript
import { Antiprime } from 'antiprime';
const ap = new Antiprime(33);
console.log(ap.isAntiprime()); //Outputs: falseAPI
new Antiprime(n);
new HighlyCompositeNumber(n); //aliasCreates a new Antiprime class object.
Properties
valueThe positive integer value currently stored in the Antiprime object.
Functions
previousAntiprime()
previousHighlyCompositeNumber() //aliasReturns a new Antiprime object where value is equal to the next lowest Antiprime number.
nextAntiprime()
nextHighlyCompositeNumber() //aliasReturns a new Antiprime object where value is equal to the next largest Antiprime number.
getFactors()Returns an array of numbers that include all factors including the 1 and value.
getPrimeFactors()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
factors(n)Takes an input integer n and returns all factors of the input as an array of numbers.
isAntiprime(n, pf)
isHighlyComposite(n, pf) //aliasTakes 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.
isAntiprimeCandidate(n, pf)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
kprime factors are equal to the firstkprime 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. nis one of the special cases: 4 or 36.
isConsecutivePrimeFactors(pf)Takes the output of primeFactors and returns true if the k prime factors are equal to the first k prime numbers; false otherwise.
isPrime(n)Returns true if the input number n is prime; false otherwise.
isPrimeExponentsReducing(pf)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.
nextPrime(n)Returns the next prime number larger than the magnitude of n.
primeFactors(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