View Code of Problem 93

#include <stdio.h>
int f(int n) {
    int sum = 0, j;
    for (j = 1; j < n; j++) {
        if (n % j == 0)
            sum += j;
    }
    return sum;
}
int main() {
    int m, n, j;
    scanf("%d%d", &m, &n);
    for (int i = m; i <= n; i++) {
        j = f(i);
        if (i < j && f(j) == i)
            printf("%d %d\n", i, j);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 93