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