euler/haskell/e020.hs

9 lines
184 B
Haskell

import Data.Char (digitToInt)
factorial :: Integer -> Integer
factorial 1 = 1
factorial x = x * factorial (x - 1)
sumDigits :: Integer -> Int
sumDigits = sum . map digitToInt . show