1
0
Fork 0

Problem 30

This commit is contained in:
Jonathan Chan 2016-12-02 20:37:08 -08:00
parent 659d6b5ae9
commit 274b965cb5
2 changed files with 22 additions and 0 deletions

BIN
30 Executable file

Binary file not shown.

22
30.c Normal file
View File

@ -0,0 +1,22 @@
#include <stdio.h>
#include <stdlib.h>
int powersOfFive[10] = { 0, 1, 32, 243, 1024, 3125, 7776, 16807, 32768, 59049 };
int main (int argc, char* argv[]) {
int sumOfNum = 0;
for (int i = 200; i <= 354294; i++) {
int n = i;
int sumOfDig = 0;
while (n > 0) {
sumOfDig += powersOfFive[n % 10];
n /= 10;
}
if (sumOfDig == i) {
sumOfNum += i;
printf ("%d\n", i);
}
}
printf ("sum: %d\n", sumOfNum);
}