#include int main() { const unsigned n_max = 999999; unsigned n, m, d; for (n = 2; n <= n_max; n++) { for (d = 2, m = 1; d <= n / 2 && m <= n; d++) if (!(n % d)) m += d; if (m == n) printf("%u\n", n); } }