#C4541. Transform to One
Transform to One
Transform to One
Given a positive integer \( n \geq 1 \), you are to transform \( n \) to 1 by repeatedly applying the following operations:
- If \( n \) is even, replace \( n \) with \( \frac{n}{2} \).
- If \( n \) is odd and \( n \neq 1 \), replace \( n \) with \( 3n+1 \).
Your task is to determine the number of operations required to transform \( n \) to 1. Additionally, you need to process multiple test cases.
For example, when \( n = 6 \), the transformation sequence is:
\(6 \rightarrow 3 \rightarrow 10 \rightarrow 5 \rightarrow 16 \rightarrow 8 \rightarrow 4 \rightarrow 2 \rightarrow 1\) and the number of operations is 8.
inputFormat
The input is read from standard input (stdin) and consists of multiple lines:
- The first line contains a single integer \( T \) representing the number of test cases.
- Then \( T \) subsequent lines follow, each containing a single integer \( n \) \( (\geq 1) \).
outputFormat
For each test case, output the number of operations required to transform the given integer \( n \) to 1. Each output should be printed on a new line.
## sample4
6
19
1
27
8
20
0
111
</p>