Problem 26
http://projecteuler.net/index.php?section=problems&id=26
--Haskell (needs -package containers), 20090102 import List (elemIndex) import Maybe (fromJust) import Data.Map (findMax, fromList) search :: Int -> (Int, Int) search n = (fromJust $ search' Nothing 1 [], n) where search' :: Maybe Int -> Int -> [Int] -> Maybe Int search' _ 0 _ = Just 0 search' (Just k) _ _ = Just (k+1) search' Nothing t l = search' (elemIndex t l) (t*10`mod`n) (t:l) main = print $ snd $ findMax $ fromList $ map search [2..999]
改善の余地あり.