不使用挨式筛选法的一个高效素数判断

int judge_prime(int x)
{
    if(x==0||x==1){
        return false;
    }else if(x==2||x==3){
        return true;
    }else{
        for(int i=2;i<(int)sqrt(x);i++){
            if(x%i==0){
                return false;
            }
        }
        return true;
    }
}

猜你喜欢

转载自blog.csdn.net/zhouzi2018/article/details/80319154
今日推荐