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:
Example 2:
Example 3:
Constraints:
10 <= U <= 10^6
Tags: