1
0
Fork 0

Problem 34

This commit is contained in:
Jonathan Chan 2016-12-03 18:10:13 -08:00
parent 2427c27571
commit b89d7b5c6f
2 changed files with 20 additions and 0 deletions

BIN
34 Executable file

Binary file not shown.

20
34.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdio.h>
#include <stdlib.h>
int factorial[10] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880 };
int main (int argc, char* argv[]) {
int max = 2540160; // 7 * 9!
int sumOfNum = 0;
for (int i = 10; i <= max; i++) {
int sumOfDigFact = 0;
int remainder = i;
while (remainder > 0) {
sumOfDigFact += factorial [remainder % 10];
remainder /= 10;
}
if (sumOfDigFact == i)
sumOfNum += i;
}
printf ("%d\n", sumOfNum);
}