getPrimeFactors.js 243 Bytes Raw Blame History Permalink 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 function getPrimeFactors(num){ var i = 2; var res = []; var p =0; while(num > 1){ if(num % i === 0){ res.push(i); num /= i; i = 2; } else { i++; } } return res; } export default getPrimeFactors;