daily pastebin goal
24%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top