import "Prelude" f x = if x `mod` 2 == 0 then x `div` 2 else 3*x + 1 fd x = unfoldr (\x -> do r = f x if x == 1 then Nothing else Just (x,r) ) x //main :: [Integer] main = fd 7 -- [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2]