质数判断函数

通用,一键CV可用

bool prime(int x){
if(x == 1) return false;
if(x == 2) return true;
for (int i = 2; i * i <= x; i++){
if (x % i == 0) return false;
}
return true;

posted @ 2023-12-06 19:14  Green_wang  阅读(22)  评论(0)    收藏  举报