Problem #34
Difficulty: 5%
Digit Factorials
Solution Language: Java
Problem Statement
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: As 1! = 1 and 2! = 2 are not sums they are not included.
Approach
The solution involves:
- Determining an upper bound for the search (7 × 9! = 2,540,160)
- For each number, computing the sum of factorials of its digits
- Checking if the sum equals the original number
- Summing all such numbers (excluding 1 and 2)