首页 > 代码库 > Primality Test - C++ code

Primality Test - C++ code

refer to this article

 1 bool IsPrimeOptimizationThree(int number) 2 { 3     if(number<2) 4         return false; 5     if(number==2) 6         return true; 7     if(number%2==0) 8         return false; 9     for(int i=3;i<=sqrt(number);i += 2)10     {11         if(number%i==0)12             return false;13     }14     return true;15 }

 

Primality Test - C++ code