Skip to content

Instantly share code, notes, and snippets.

@qoelet
Created October 15, 2013 12:00
Show Gist options
  • Save qoelet/6990475 to your computer and use it in GitHub Desktop.
Save qoelet/6990475 to your computer and use it in GitHub Desktop.
-- Collatz conjecture
collatz :: Integer -> [Integer]
collatz 1 = [1]
collatz n | even n = n : collatz (n `div` 2)
| otherwise = n : collatz ((3 * n) + 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment