Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE NumericUnderscores #-}
- import Data.Array.Unboxed
- cache :: UArray Int Int
- cache = listArray (0, 9) $ 0:[i^i | i <- [1..9]]
- recourse :: (Int -> Int) -> (Int, Int) -> Int
- recourse f (q, r) = cache ! r + f q
- calc :: Int -> Int
- calc n
- | n > 0 = recourse calc $ n `quotRem` 10
- | otherwise = 0
- isMunchausen :: Int -> Bool
- isMunchausen n = (calc n) == n
- main = do
- mapM_ print $ filter (\i -> isMunchausen i) [0 .. 440_000_000]
- return 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement