antiprime
    Preparing search index...

    Function primeFactors

    • Finds the prime factorisation of a number.

      Parameters

      • n: number

        A non-zero safe integer.

      Returns PrimeFactor[]

      The prime factors of n in ascending order, each with an exponent of at least 1.

      Negative numbers are judged by their absolute value. The prime factorisation of 1 is empty.

      TypeError If n is not a number.

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

      1.0.0

      primeFactors(360); // [{ factor: 2, exponent: 3 }, { factor: 3, exponent: 2 }, { factor: 5, exponent: 1 }]
      primeFactors(1); // []