#K4156. Collatz Sequence Analysis
Collatz Sequence Analysis
Collatz Sequence Analysis
This problem involves analyzing the famous Collatz sequence. Given an integer \( N \), you are required to generate the sequence based on the following rules:
- If \( N \) is even, then \( N = \frac{N}{2} \).
- If \( N \) is odd, then \( N = 3N + 1 \).
The sequence terminates when \( N = 1 \). Your task is to determine:
- The length of the sequence (i.e., the number of terms including the starting number).
- The maximum value encountered in the sequence. </p>
You will be given multiple test cases. For each test case, output the sequence length and the maximum value separated by a space.
inputFormat
The first line contains an integer \( T \) representing the number of test cases. Each of the following \( T \) lines contains a single integer \( N \), for which you must calculate the required Collatz sequence information.
outputFormat
For each test case, output a single line containing two space-separated integers: the length of the Collatz sequence and the maximum value encountered in the process.
## sample3
5
3
6
6 16
8 16
9 16
</p>