fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n;
  7. int f = 1;
  8. cout << "Enter an integer: ";
  9. cin >> n;
  10.  
  11. for (int i = 1; i <= n; i++)
  12. {
  13. f=1;
  14. cout << "| " << i << ": ";
  15. while (f <= i) {
  16. if (i%f == 0)
  17. {
  18. cout << f<<" ";
  19. }
  20. f++;
  21. }
  22. cout<<"\n";
  23. }
  24. cout << endl;
  25. }
Success #stdin #stdout 0s 3464KB
stdin
8
stdout
Enter an integer: | 1: 1 
| 2: 1 2 
| 3: 1 3 
| 4: 1 2 4 
| 5: 1 5 
| 6: 1 2 3 6 
| 7: 1 7 
| 8: 1 2 4 8