-- Collatz Conjecture Length
-- /

module Codewars.Kata.Collatz where

import Data.List (unfoldr)

collatz = length . unfoldr f
    where f n | n == 0 = Nothing
              | n == 1 = Just (1, 0)
              | even n = Just (n, n `div` 2)
              | otherwise = Just (n , (n * 3) + 1)

 Collatz Conjecture Length
 /

module Codewars.Kata.Collatz where

import Data.List (unfoldr)

collatz = length . unfoldr f
    where f n | n == 0 = Nothing
              | n == 1 = Just (1, 0)
              | even n = Just (n, n `div` 2)
              | otherwise = Just (n , (n * 3) + 1)
