fork download
  1. #include <cmath>
  2. #include <iostream>
  3.  
  4. int sumDiv(int x)
  5. {
  6. int s = 0;
  7. for(int i = 1; i < x; ++i)
  8. {
  9. if(x % i == 0)
  10. s += i;
  11. }
  12. return s;
  13. }
  14.  
  15. int main()
  16. {
  17. for(int i = 1; i <= 2000; ++i)
  18. {
  19. int a = sumDiv(i);
  20. if(a == i)
  21. std::cout << i << std::endl;
  22. }
  23. }
Success #stdin #stdout 0.03s 2896KB
stdin
Standard input is empty
stdout
6
28
496