This is the Collatz Conjecture (OEIS A006577):
- Start with an integer n > 1.
- Repeat the following steps:
- If n is even, divide it by 2.
- If n is odd, multiply it by 3 and add 1.
It is proven that for all positive integers up to 5 * 260, or about 5764000000000000000, n will eventually become 1.
Your task is to find out how many iterations it takes (of halving or tripling-plus-one) to reach 1.
- Shortest code wins.
- If a number < 2 is input, or a non-integer, or a non-number, output does not matter.
2 -> 1 16 -> 4 5 -> 5 7 -> 16