Flight of the Syracuse
As part of a project to make the ENS Rennes great again, the five departments of the school assembled to complete a project that will send the first Normalian student in the airs in a glider, that we chose to call the Syracuse. In order to fulfill our mission, we decided to organize ourselves. The Mécatros will be in charge of building the plane, while a bunch of 2SEP will man it. The people from the Math department will have to solve partial differential equations for the Mécatros, and the DEMs will, hum...?
As a proud Info, you will be in charge of the simulations. The Math department managed to find a way to predict the altitude of the glider. If, at kilometer \(n\), the glider is at altitude \(a_n\), then we have :
\[a_{n+1} = \begin{cases} \dfrac{a_n}{2}& \mbox{if } a_n \mbox{ is even,}\\ 3a_n + 1 & \mbox{if } a_n \mbox{ is odd.} \end{cases}\]
(Well, the glider behaves in a weird way, but hey, that's not my fault. Blame the Mécatros for their design.)
It is easy to show that, whatever the starting altitude \(a_0\) is, if the glider keeps gliding, it will go to altitude \(a_N = 1\) meter, at a certain kilometer \(N\) that depends on \(a_0\). The Math people want to test a few starting altitudes, and see how far the glider will go before biting the dust at altitude 1m.
Input
On the first line, an integer \(T \leq 200\), the number of test cases.
On the next \(T\) lines, an integer \(a_0^i \leq 15000\) for each line, representing the starting altitude of test case \(i\).
Output
For each test case, the value \(N_i\) of the first kilometer such that the altitude is equal to 1.
Sample Input
2
4
7
Sample Output
2
16
Comments
Si le problème se résout trop rapidement, n'hésitez pas à prouver le petit lemme qui dit que le planeur va finir par se crasher ! Je n'avais pas assez de place dans la marge pour mettre la preuve ici.