MeehoweCK

Untitled

Apr 18th, 2023
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int liczba;
  8.     cout << "Podaj liczbe naturalna: ";
  9.     cin >> liczba;
  10.  
  11.     cout << 1 << ", ";
  12.  
  13.     int i;
  14.  
  15.     for(i = 2; i * i < liczba; ++i)
  16.     {
  17.         if(liczba % i == 0)
  18.         {
  19.             cout << i << ", " << liczba / i << ", ";
  20.         }
  21.     }
  22.     if(i * i == liczba)
  23.         cout << i << ", ";
  24.     cout << liczba << endl;
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment