#C2836. Steps to One
Steps to One
Steps to One
You are given a positive integer \(S\). Your task is to determine the number of operations required to reduce \(S\) to 1 using the following process:
- If \(S\) is even, divide it by 2, i.e., \(S \leftarrow \frac{S}{2}\).
- If \(S\) is odd, multiply it by 3 and add 1, i.e., \(S \leftarrow 3S+1\).
Repeat the process until \(S\) becomes 1. This is a well-known procedure related to the Collatz conjecture. For each test case, output the number of operations required.
inputFormat
The first line of the input contains an integer \(T\) representing the number of test cases. Each of the following \(T\) lines contains a single integer \(S\) representing the starting value.
Input Format:
T S1 S2 ... ST
outputFormat
For each test case, output a single integer which is the number of operations required to reduce \(S\) to 1. Each result should be printed on a new line.
## sample3
6
1
7
8
0
16
</p>