summaryrefslogtreecommitdiff
path: root/haskell/p377.hs
blob: f511046bc3d5d23e31e3d3dd1b6ecb4f93da7874 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
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