minPrimeFactor - nodef/extra-math GitHub Wiki

Find the least prime number which divides a number.

Similar: minPrimeFactor, maxPrimeFactor, primeFactors.

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


xmath.minPrimeFactor(1);
// → 0

xmath.minPrimeFactor(3);
// → 3

xmath.minPrimeFactor(21);
// → 3

xmath.minPrimeFactor(55);
// → 5

xmath.minPrimeFactor(53);
// → 53

References