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