题解 | #质数因子#
质数因子
http://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
// 主要是要明确指数因子的范围
// 小于等于本身,小于等于本身的开方
const line = readline();
function func(line) {
let num = parseInt(line);
let arr = [];
let i = 2;
while( i <= num && i * i <= num ) {
if (num % i === 0) {
arr.push(i);
num /= i;
i = 2;
} else {
i++;
}
}
if (num !== 1) {
arr.push(num);
}
print(arr.join(' '));
}
func(line);