fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int n;
  7. cin >> n;
  8.  
  9. if(n <= 0){
  10. cout << -1 << endl;
  11. return 0;
  12. }
  13.  
  14. for(int i = 1; i * i <= n; i++){
  15. if(n % i == 0){
  16. cout << i << endl;
  17.  
  18. if(i != n / i)
  19. cout << n / i << endl;
  20. }
  21. }
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 5312KB
stdin
36
stdout
1
36
2
18
3
12
4
9
6