AI智能
改变未来

js写1到1000以内的素数(质数)

<!DOCTYPE html><html leng = \'en\'><head><meta charset = \'UTF-8\'/></head><body><script>function prime(){for(var i = 2; i <= 1000; i++){var num = 0;for(var j = 2; j <= 1000; j++){if(i % j === 0){num++;}}if(num === 1){console.log(i);}}}prime();</script></body></html>
赞(0) 打赏
未经允许不得转载:爱站程序员基地 » js写1到1000以内的素数(质数)