collatz chain


See On Github

Data

Contributor

Generic placeholder thumbnail

by warreee

in haskell

Tags

Source Code

module CollatzChain ( chain ) where

chain :: Int -> [Int]
chain 1 = [1]
chain n
    | even n = n:chain (n `div` 2)
    | odd n = n:chain (n*3 + 1)
module CollatzChain_test (main) where
import CollatzChain ( chain )

main = do
    putStrLn "Collatz Chain with number 30: "
    putStrLn $ show $ chain 30