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 }

 

posted @ 2014-11-21 10:09  Rui Yan  阅读(236)  评论(0编辑  收藏  举报