"Quick judgment primes, 10^9"

Source: Internet
Author: User

See a very god template, specifically what meaning still do not understand, first horse to study again ~

1 BOOLPrime (Long Longnum)2 {  3     if(num = =2|| num = =3|| num = =5)  4         return true; 5     if(num%2==0|| Num%3==0|| Num%5==0|| num = =1)  6         return false; 7   8     Long Longc =7; 9     intMAXC = (int) (sqrt (num)); Ten      while(c <=maxc) One     {   A         if(num% c = =0)   -             return false;  -c + =4;  the         if(num% c = =0)   -             return false;  -c + =2;  -         if(num% c = =0)   +             return false;  -c + =4;  +         if(num% c = =0)   A             return false;  atc + =2;  -         if(num% c = =0)   -             return false;  -c + =4;  -         if(num% c = =0)   -             return false;  inc + =6;  -         if(num% c = =0)   to             return false;  +c + =2;  -         if(num% c = =0)   the             return false;  *c + =6;  $     }  Panax Notoginseng     return true;  -}

"Quick judgment primes, 10^9"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.