fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6. unsigned long long M;
  7. cin >> M;
  8. for (unsigned long long n = 4; n <= M; n += 2) {
  9. unsigned long long S = 1;
  10. for (unsigned long long j = 2; j <= sqrt(n) && S <= n; j++) {
  11. if (n % j == 0) S += n / j + j;
  12. }
  13. if (n == S) cout << n << " ";
  14. }
  15. return 0;
  16. }
Success #stdin #stdout 3.02s 3472KB
stdin
2000000
stdout
6 28 496 8128