Consider the following operation on an arbitrary positive integer:
n is even -> n / 2n is odd -> n * 3 + 1Create a function to repeatedly evaluate these operations, until reaching 1. Return the number of steps it took.
See the following example, using 10 as the input, with 6 steps:
6collatzConjecture(2) ➞ 1
collatzConjecture(3) ➞ 7
collatzConjecture(10) ➞ 6For further information, check the Resources tab.