9 lines
214 B
Haskell
9 lines
214 B
Haskell
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..]
|