Self powers
The series, 11 + 22 + 33 + … + 1010 = 10405071317.
Find the last ten digits of the series, 11 + 22 + 33 + … + 10001000.
自幂
十项的自幂级数求和为 11 + 22 + 33 + … + 1010 = 10405071317。
求如下一千项的自幂级数求和的最后10位数字:11 + 22 + 33 + … + 10001000。
#include<stdio.h>
#include<math.h>
long long power(int n)
{
long long ans = 1;
for (int i = 1; i <= n; i++) {
ans *= n;
ans %= 10000000000;
}
return ans;
}
int main()
{
long long sum = 0;
for (int i = 1; i <= 1000; i++) {
sum += power(i);
sum %= 10000000000; //取模,只保留最低的10位
}
printf("%lld\n", sum);
return 0;
}
Answer:9110846700
Completed on Mon, 20 Aug 2018, 18:24
Comments