MeehoweCK

Untitled

Feb 5th, 2023
805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main (int argc, const char * argv[])
  5. {
  6.     cout << "Program, ktory sprawdza czy liczba jest pierwsza: ";
  7.     int n;
  8.     cin >> n; //wpisanie liczby
  9.  
  10.     if (n <= 1)
  11.     {
  12.         cout << "NIE" << endl;
  13.         return 0;
  14.     }
  15.     bool flaga = true;
  16.     for(int i = 2; i*i <= n; ++i)
  17.         if(n % i == 0)
  18.         {
  19.             flaga = false;
  20.             break;
  21.         }
  22.     if(flaga)
  23.         cout << "TAK\n";
  24.     else
  25.         cout << "NIE\n";
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment