CT101

Digit Factorials

MediumAcceptance: 0.0%

145 is curious: 1! + 4! + 5! = 1 + 24 + 120 = 145. Given upper bound U, find the sum of all numbers <= U which are equal to the sum of the factorial of their digits. (Note: 1! = 1 and 2! = 2 are not sums, so they are not included.)

Example 1:

Input: 50000
Output: 40730

Example 2:

Input: 1000
Output: 145

Example 3:

Input: 100000
Output: 40730

Constraints:

10 <= U <= 10^6

Tags:

math factorial digit-sum
Loading...
Test Cases:No test cases
No test cases available.
Coding Problem Not Found | CodeTikki