Number质数
作者:互联网
const number = 180; let arr = []; let flag = true; getPrime(number); print(arr.join(' ')); function getPrime(num) { if (num === 1) { return null; } for (let i = 2; i <= num/i; i++) { if (Math.ceil(num/i) === num/i){ arr.push(i); getPrime(num/i); flag = false; break; } } if (flag) { arr.push(num); } }
标签:arr,质数,Number,number,num,let,getPrime 来源: https://www.cnblogs.com/lizzy-yang/p/15916433.html