update: 优化质数代码
This commit is contained in:
parent
82cb959009
commit
7b6340e357
@ -371,9 +371,10 @@ i的值:9
|
|||||||
//console.log(i);
|
//console.log(i);
|
||||||
//判断num是否能被i整除
|
//判断num是否能被i整除
|
||||||
if (num % i == 0) {
|
if (num % i == 0) {
|
||||||
//如果num能被i整除,则说明num一定不是质数
|
//一旦发现:如果num能被i整除,则说明num一定不是质数,
|
||||||
//设置flag为false
|
//此时:设置flag为false,然后跳出 for 循环
|
||||||
flag = false;
|
flag = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user