irapilguy

Untitled

Nov 24th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. void divid(int x, int i) {
  4.     if (x == 1) return;
  5.     if (i*i > x) {
  6.         cout << x;
  7.         return;
  8.     }
  9.     if (x % i == 0) {
  10.         cout << i << " ";
  11.         divid(x / i, i);
  12.     }
  13.     else {
  14.         divid(x, i + 1);
  15.     }
  16. }
  17. int main() {
  18.     ios_base::sync_with_stdio(false);
  19.     cin.tie(NULL);
  20.     cout.tie(NULL);
  21.     int x;
  22.     cin >> x;
  23.     if (x == 1) {
  24.         cout << "1";
  25.         return 0;
  26.     }
  27.     divid(x, 2);
  28.     return 0;
  29. }
Add Comment
Please, Sign In to add comment