1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-27 08:26:20 +00:00
202401-programming-assignments/【实践课内】6.循环结构3/7-2 21循环-求和2.c

23 lines
344 B
C

#include <math.h>
#include <stdio.h>
int main() {
long long n, ans = 0;
scanf("%lld", &n);
for (long long i = 1; i <= (long long)sqrt(n); i++) {
if (n % i == 0) {
ans += i;
if (i != n / i) {
ans += n / i;
}
}
}
printf("%lld\n", ans);
return 0;
}