euler/Problem034.hs

11 lines
316 B
Haskell

-- 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.
import Euler
factorial n = product [1..n]
factSum n = sum $ map factorial $ toDigits n
main = print $ sum $ filter (\n -> n == factSum n) [10..2540160]