- module CollatzConjecture
-
- let rec countSteps counter n =
- match n with
- | 1 -> counter
- | _ when n % 2 = 0 -> countSteps (counter + 1) (n / 2)
- | _ -> countSteps (counter + 1) (n * 3 + 1)
-
- let steps (number: int): int option =
- match number with
- | _ when number < 1 -> None
- | _ -> Some(countSteps 0 number)
|