Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. bool czy_pierwsza(unsigned liczba)
  6. {
  7.     if(liczba==0||liczba==1)
  8.     {
  9.         return false;
  10.     }
  11.     for(unsigned i=2; i*i<=liczba; i++)
  12.     {
  13.         if(liczba%i==0)
  14.         {
  15.             return false;
  16.         }
  17.     }
  18.     return true;
  19. }
  20.  
  21. int main()
  22. {
  23.     unsigned n;
  24.     cin>>n;
  25.     if(czy_pierwsza(n))
  26.         cout << "Liczba " << n << " jest liczba pierwsza." << endl;
  27.     else
  28.         cout << "Liczba " << n << " nie jest liczba pierwsza." << endl;
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement