Guest User

Untitled

a guest
Nov 19th, 2023
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.18 KB | None | 0 0
  1. collatz :: Int -> [Int]
  2. collatz x = if (x == 1)
  3. []
  4. if even x then
  5. (div x 2) : (collatz (div x 2))
  6. else
  7. 3*x+1 : (collatz (3*x+1))
  8. main = print (collatz (4 :: Int))
Advertisement
Add Comment
Please, Sign In to add comment