Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void divid(int x, int i) {
- if (x == 1) return;
- if (i*i > x) {
- cout << x;
- return;
- }
- if (x % i == 0) {
- cout << i << " ";
- divid(x / i, i);
- }
- else {
- divid(x, i + 1);
- }
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- int x;
- cin >> x;
- if (x == 1) {
- cout << "1";
- return 0;
- }
- divid(x, 2);
- return 0;
- }
Add Comment
Please, Sign In to add comment