primeFactors - nodef/extra-math GitHub Wiki

Find the prime factors of a number.

Similar: minPrimeFactor, maxPrimeFactor, primeFactors. Similar: properDivisors, primeFactors, primeExponentials, isPrime.

function primeFactors(x)
// x: a number
const xmath = require('extra-number');


xmath.primeFactors(1);
// → []

xmath.primeFactors(3);
// → [3]

xmath.primeFactors(21);
// → [3, 7]

xmath.primeFactors(55);
// → [5, 11]

xmath.primeFactors(53);
// → [53]

References