Difficulty: Easy
The Collatz function is defined for a positive integer n as follows.
The Collatz function is defined for a positive integer n as follows.
f(n) = 3n+1 if n is odd
n/2 if n is even
We consider the repeated application of the Collatz function starting with a given integer n, as follows:
f(n), f(f(n)), f(f(f(n))), …
It is conjectured that no matter which positive integer n you start from, this sequence eventually will have 1 in it. It has been verified to hold for numbers up to 5 × 260 [Wikipedia: Collatz Conjecture].