bool isPrime(int n){
if(n<=3) return n>1;
if(n % 2 == 0 || n % 3 == 0) return false;
int k = sqrt(n)+1;
for(int i = 5; i<k; i += 6)
if(n % i == 0 || n%(i + 2) == 0) return false;
return true;
}
转载于:https://www.cnblogs.com/lepeCoder/p/sexy-prime.html