fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. long long n;
  6. cin >> n;
  7. for(int i = 2;i <= sqrt(n);i++){
  8. while(n % i == 0){
  9. cout << i << " ";
  10. n /= i;
  11. }
  12. }
  13. if(n > 1){
  14. cout << n;
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0.01s 5320KB
stdin
123
stdout
3 41