Advertisement
Josif_tepe

Untitled

Feb 23rd, 2024
1,113
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. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int x;
  7.     cin >> x;
  8.    
  9.     int koren = sqrt(x);
  10.     for(int i = 1; i <= koren; i++) {
  11.         if(x % i == 0) {
  12.             cout << i << " ";
  13.             if(i != x / i) {
  14.                 cout << x / i << " " << endl;
  15.             }
  16.         }
  17.     }
  18.    
  19.     return 0;
  20. }
  21. // 1, 2, 4, 8, 16, 22, 24, 28, 36, 42, 44, 48, 56
  22. // 1, 2, 3, 4, 5,  6,  7,  8,  9,  10, 11, 12, 13
  23.  
  24.  
  25. // 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 44, 48, 52
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement