Perfect numbers: Difference between revisions

Line 230:
}
int max = cast(int) sqrt(cast(real) n) + 1;
int totsum = 1;
for (int i = 2; i < max; i++) {
if (n % i == 0) {
totsum += i;
int q = n / i;
if (q > i) {
totsum += q;
}
}
}
return totsum == n;
}
Anonymous user