We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int n;
scanf("%d",&n);
unsigned long long int sum=0;
for (long i =2; i<1000000; i++) {
long temp = i;
unsigned long long int sum1 = 0;
while (temp>0) {
int a = temp%10;
sum1 +=(unsigned long long int) pow(a, n);
temp = temp/10;
}
if (sum1 == i) {
sum += sum1;
}
}
printf("%lld",sum);
return 0;
Project Euler #30: Digit Nth powers
You are viewing a single comment's thread. Return to all comments →
code in c
int main() {
}