euler/haskell/e014.hs

9 lines
214 B
Haskell
Raw Normal View History

2015-01-04 23:52:50 +01:00
collatz :: Integral a => a -> [a]
collatz 1 = 1:[]
collatz x
| even x = x:collatz (quot x 2)
| odd x = x:collatz (3*x + 1)
main = do
putStrLn . show $ maximum $ zip (map (length . collatz) [1..1000000]) [1..]