function printPrimeFactor(n : number) {
let div = 2;
while (n !== 0) {
if (n % div !== 0) {
div = div + 1;
}
else {
console.log(div);
n = n / div;
if (n == 1) {
break;
}
}
}
console.log("\n");
}
const n = 124;
printPrimeFactor(n); // 2 * 2 * 32
printPrimeFactor(1591); // 37 * 43
printPrimeFactor(1764); // 2 * 2 * 3 * 3 * 7 * 7
/*
run:
2
2
31
37
43
2
2
3
3
7
7
*/