#K72877. Taco Sequence Length
Taco Sequence Length
Taco Sequence Length
This problem challenges you to compute the length of a sequence defined by the following rules, which are reminiscent of the Collatz Conjecture. Given an integer \(n\), if \(n\) is even, the next number is \(\frac{n}{2}\); if \(n\) is odd, the next number is \(3n + 1\). The sequence ends when it reaches 1, and your task is to determine the total number of terms in the sequence.
Example:
Input: 7 Sequence: 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 Output: 17
Ensure that your solution reads from standard input and writes the result to standard output.
inputFormat
The input consists of a single integer \(n\) (\(n \ge 1\)) provided via standard input.
outputFormat
Output the length of the sequence (i.e. the number of terms from \(n\) to 1) to standard output.
## sample7
17
</p>