MeehoweCK

Untitled

Dec 17th, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. bool czy_pierwsza(unsigned x)
  7. {
  8.     if(x == 1)
  9.         return false;
  10.     if(x == 2)
  11.         return true;
  12.     for(unsigned i = 2; i <= pow(x,0.5); ++i)
  13.     {
  14.         if(x % i == 0)
  15.             return false;
  16.     }
  17.     return true;
  18. }
  19.  
  20. int main()
  21. {
  22.     cout << czy_pierwsza(170) << endl;
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment