0
0
GGGiovanny Gongora
Finds the prime factors of a given number using the trial division algorithm.
const primeFactors = (n: number) => {
let a: Array<number> = [],
f = 2;
while (n > 1) {
if (n % f === 0) {
a.push(f);
n /= f;
} else {
f++;
}
}
return a;
};