#C1673. The Life Span Transformation Challenge

    ID: 44904 Type: Default 1000ms 256MiB

The Life Span Transformation Challenge

The Life Span Transformation Challenge

You are given a positive integer \(n\). Your task is to compute the number of transformations required to reduce \(n\) to 1 using a special transformation function \(f\), defined as follows:

\(\displaystyle f(n)=\begin{cases}\frac{n}{2}&\text{if }n\text{ is even},\\3n+1&\text{if }n\text{ is odd}.\end{cases}\)

Repeatedly apply \(f\) on \(n\) until you reach 1. The required output is the count of transformations performed.

For example, if \(n = 6\), the sequence is: 6 \(\to\) 3 \(\to\) 10 \(\to\) 5 \(\to\) 16 \(\to\) 8 \(\to\) 4 \(\to\) 2 \(\to\) 1, making a total of 8 transformations.

inputFormat

Input is read from stdin. It consists of a single integer, (n) (1 (\leq) (n)).

outputFormat

Output a single integer representing the number of transformations required to reduce (n) to 1. The output is printed to stdout.## sample

6
8