Shidongan

SimpleNum

Jun 18th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.17 KB | None | 0 0
  1. bool simpleNum(int num)
  2. {
  3.     if (num % 2 == 0) {
  4.         return false;
  5.     }
  6.     for (int i = 3; i <= sqrt(num); i+=2) {
  7.         if (num % i == 0) {
  8.             return false;
  9.         }
  10.     }
  11.     return true;
  12. }
Add Comment
Please, Sign In to add comment