antiprime
    Preparing search index...

    Class Antiprime

    A non-zero integer together with its antiprime and superior antiprime status, factors and prime factorisation.

    Also exported as HighlyCompositeNumber. Despite the name, an instance can hold any non-zero safe integer: use Antiprime.isAntiprime to check whether its value is an antiprime. The instances returned by Antiprime.nextAntiprime, Antiprime.previousAntiprime, Antiprime.nextSuperiorAntiprime and Antiprime.previousSuperiorAntiprime always hold antiprimes.

    Negative numbers are judged by their absolute value. Everything except the value is worked out on first use and cached.

    1.0.0

    const ap = new Antiprime(10);
    ap.isAntiprime(); // false
    ap.nextAntiprime().value; // 12
    Index
    • Creates an instance holding the absolute value of n, which need not be an antiprime.

      Parameters

      • n: number

        A non-zero safe integer.

      Returns Antiprime

      TypeError If n is not a number.

      RangeError If n is zero, not an integer, or outside the safe integer range.

    • get factorCount(): number

      How many factors the value has.

      Returns number

      The number of factors of Antiprime.value, including 1 and the value itself.

      2.0.0

      new Antiprime(12).factorCount; // 6
      
    • get value(): number

      The number this instance holds, which is always positive.

      Returns number

      The absolute value of the number the instance was created with.

      1.0.0

      new Antiprime(-12).value; // 12
      
    • Lists every factor of the value.

      Returns number[]

      A new array of the factors in ascending order, which the caller may change freely.

      1.0.0

      new Antiprime(12).getFactors(); // [1, 2, 3, 4, 6, 12]
      
    • Finds the prime factorisation of the value.

      Returns PrimeFactor[]

      A new array of new prime factor objects in ascending order, which the caller may change freely.

      1.0.0

      new Antiprime(12).getPrimeFactors(); // [{ factor: 2, exponent: 2 }, { factor: 3, exponent: 1 }]
      
    • Determines whether the value is an antiprime.

      Returns boolean

      true if the value has more factors than any smaller positive integer; otherwise false.

      1.0.0

      new Antiprime(12).isAntiprime(); // true
      new Antiprime(10).isAntiprime(); // false
    • Returns boolean

      true if the value has more factors than any smaller positive integer; otherwise false.

      1.0.0

      new HighlyCompositeNumber(12).isHighlyCompositeNumber(); // true
      
    • Determines whether the value is a superior antiprime.

      Returns boolean

      true if the value is a superior antiprime; otherwise false.

      The first superior antiprime is 2: 1 is excluded by convention, even though it is the first antiprime.

      2.1.0

      new Antiprime(60).isSuperiorAntiprime(); // true
      new Antiprime(24).isSuperiorAntiprime(); // false, though 24 is an antiprime
    • Returns boolean

      true if the value is a superior antiprime; otherwise false.

      2.1.0

      new HighlyCompositeNumber(60).isSuperiorHighlyCompositeNumber(); // true
      
    • Finds the smallest antiprime larger than the value.

      Returns Antiprime

      A new instance holding the next antiprime.

      RangeError If the next antiprime is larger than Number.MAX_SAFE_INTEGER.

      1.0.0

      new Antiprime(12).nextAntiprime().value; // 24
      new Antiprime(720720).nextAntiprime().value; // 1081080
    • Returns Antiprime

      A new instance holding the next antiprime.

      RangeError If the next antiprime is larger than Number.MAX_SAFE_INTEGER.

      1.0.0

      new HighlyCompositeNumber(12).nextHighlyCompositeNumber().value; // 24
      
    • Finds the smallest superior antiprime larger than the value.

      Returns Antiprime

      A new instance holding the next superior antiprime.

      RangeError If the next superior antiprime is larger than Number.MAX_SAFE_INTEGER.

      2.1.0

      new Antiprime(1).nextSuperiorAntiprime().value; // 2
      new Antiprime(5040).nextSuperiorAntiprime().value; // 55440
    • Returns Antiprime

      A new instance holding the next superior antiprime.

      RangeError If the next superior antiprime is larger than Number.MAX_SAFE_INTEGER.

      2.1.0

      new HighlyCompositeNumber(5040).nextSuperiorHighlyCompositeNumber().value; // 55440
      
    • Finds the largest antiprime smaller than the value.

      Returns Antiprime

      A new instance holding the previous antiprime.

      RangeError If the value is 1, the smallest antiprime.

      1.0.0

      new Antiprime(12).previousAntiprime().value; // 6
      new Antiprime(10).previousAntiprime().value; // 6
    • Finds the largest superior antiprime smaller than the value.

      Returns Antiprime

      A new instance holding the previous superior antiprime.

      RangeError If the value is 1 or 2, since 2 is the smallest superior antiprime.

      2.1.0

      new Antiprime(5040).previousSuperiorAntiprime().value; // 2520
      new Antiprime(100).previousSuperiorAntiprime().value; // 60
    • Returns Antiprime

      A new instance holding the previous superior antiprime.

      RangeError If the value is 1 or 2, since 2 is the smallest superior antiprime.

      2.1.0

      new HighlyCompositeNumber(5040).previousSuperiorHighlyCompositeNumber().value; // 2520