1
0
Fork 0

Problem 63

This commit is contained in:
Jonathan Chan 2017-05-28 22:00:17 -07:00
parent f561cc33c3
commit b6b1b2c91a
4 changed files with 11 additions and 0 deletions

BIN
63 Executable file

Binary file not shown.

BIN
63.hi Normal file

Binary file not shown.

11
63.hs Normal file
View File

@ -0,0 +1,11 @@
digits :: Integer -> Integer
digits n = 1 + (floor . logBase 10 . fromIntegral $ n)
powerDigits :: Integer -> Integer -> Bool
powerDigits n p = digits (n ^ p) == p
powers = takeWhile (powerDigits 9) [1..]
count = sum $ map (\n -> sum $ map (\p -> if powerDigits n p then 1 else 0) powers) [1..9]
main = do print count

BIN
63.o Normal file

Binary file not shown.