Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- collatz :: Int -> [Int]
- collatz x = if x == 1
- []
- else
- if even x then
- div x 2 : collatz (div x 2)
- else
- 3*x+1 : collatz (3*x+1)
- main = print (collatz (4 :: Int))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement