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

23 lines
344 B
C
Raw Normal View History

2024-11-01 08:36:33 +00:00
#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;
}