求1-1024中的质数

版权声明:版权声明:转发文档者,请注明转发出处 https://blog.csdn.net/han123__/article/details/83349089

let ll = [2];
let ls  = [2];
for(let i=3;i<=1024;i++){
  let count = 0;
  for(let j=2;j<=i-1;j++){
     if(i%j==0){
       count++;
     }
  }
  if(count==0){
    ll.push(i)
  }
}

console.log(ll,"---------------ll---------------")

猜你喜欢

转载自blog.csdn.net/han123__/article/details/83349089