// Project Euler Problem #30
// sum of fifth powers of digits
#include <stdio.h>
int pow5(int i) { // pow() from math.h didn't link into my program for some reason
return i*i*i*i*i;
}
main() {
int i, sum=0;
for (i=2; i<200000; i++) {
int temp=i, tempsum=0;
while (temp) {
tempsum += pow5(temp%10);
temp /= 10;
}
if (tempsum == i) {
sum += i;
printf("Solution found: %d, sum: %d\n", i, sum);
}
}
}
Comments (0)
You don't have permission to comment on this page.