Let be any strictly positive natural number. Consider the following process. If is an even number, we divide it by two. Otherwise, we multiply it by 3 and add 1 to it. When we reach 1, we stop. For instance, starting with 3, we obtain the sequence
Since 1937 it is conjectured that this process ends for any initial , although nobody has been able to prove it. In this problem, we do not ask you for a proof. You only have to write a program that prints the number of steps that it takes to reach 1 for every given .
Input consists of several natural numbers .
For every , print how many steps are needed to reach 1. Suppose that this number is well defined, that is, that the conjecture of the statement is true.
Author: Unknown
Translator: Carlos Molina
Generation: 2026-01-25T11:51:02.508Z
© Jutge.org, 2006–2026.
https://jutge.org