http://acm.uva.es/problemset/ の問題を解こう
今度はこれ。http://acm.uva.es/p/v1/100.html
暇なわけではないです。
import Control.Monad import System f :: Integer -> Int f n = length (takeWhile (/=1) $ iterate g n) + 1 where g x | even x = x `div` 2 | otherwise = 3*x + 1 main :: IO () main = do input <- liftM words getLine case input of [a, b] -> do let answer = maximum $ map f [read a..read b] putStrLn $ a++" "++b++" "++show answer main _ -> return ()