题解 | #字符串分隔#
质数因子
http://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
const readline = require('readline') var rl = readline.createInterface({ input:process.stdin, output:process.stdout }) var num = 0 rl.on('line',(line)=>{ num = parseInt(line) }) rl.on('close',()=>{ var res = '' var i = 2 // num等于1找到最后一个质数 while(num != 1){ // 取余等于0,说明这个质数不在会出现,此时i++,换下一个进行循环 while(num % i == 0){ res = res + i + ' ' num = num / i } i++ } console.log(res) })