Ad
Sequences
Arrays
Data Types

Returns the Collatz sequence starting with the given number.

module Collatz where

collatz :: Int -> [Int]
collatz n = n : collatz next
  where next | even n = n `div` 2
             | odd n = n * 3 + 1