自己写的。C语言。题解 | #完全数计算#
完全数计算
https://www.nowcoder.com/practice/7299c12e6abb437c87ad3e712383ff84
#include<stdio.h> int main() { int n, i, j, count = 0, sum; scanf("%d", &n); for (i = 2; i <= n; i++) { sum = 1; for (j = 2; j < i; j++) { if (i % j == 0) { sum += j; } } if (sum == i) { count++; } } printf("%d\n", count); return 0; }