Advertisement
Guest User

Untitled

a guest
Oct 25th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. isMunchausen :: Int -> Int -> Int -> [Int] -> Bool
  2. isMunchausen number n total cache
  3.   | total > number = False
  4.   | n > 0 = isMunchausen number (n `div` 10) (total + (cache !! (n `mod` 10))) cache
  5.   | otherwise = number == total
  6.  
  7. main = do
  8.   let cache = [0] ++ [i ^ i | i <- [1 .. 9]]
  9.   mapM_ print $ filter (\i -> isMunchausen i i 0 cache) [0 .. 440000000]
  10.   return 0
  11.  
  12.  
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement