import Data.Char f :: Int -> Integer f n = sum [x | x <- [1..10^n], nozero x, sumn x n] where nozero x = notElem '0' (show x) sumn x n = sum (map digitToInt (show x)) == n p377 :: String p377 = reverse . (take 9) . reverse . show $ sum [f 13^i | i <- [1..17]] main = putStrLn $ "Solution: " ++ p377