1.从N开始递减,找到满足 : n%i ==0 && n是素数 -> result
2.存result到数组,递归执行(n/result)
var result = new Array();
var factor = function f(n){
if(n == 1){return ;}
var n1 = n;
while(n1>1){
if(isPrime(n1) && n % n1 == 0) {break;}
n1--;
}
if(n1 == 1){return ;}
result.push(n1);
f(n / n1);
}
var isPrime = function (n){
for(var i = 2; i < n ; i++){if(n%i == 0){return false;}}
return true;
}
factor(45);
console.log(result);