Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/while-kollats-ketma-ketligi

Collatz sequence

Medium 1000 ms 64 MB 51%
Share

A positive integer $n$ is given. While $n \ne 1$, the following operation is performed:

$$n \to \begin{cases} \frac{n}{2}, & n \text{ even}, \\ 3 * n + 1, & n \text{ odd}. \end{cases}$$

Find after how many operations $n = 1$, and the largest number met during the process (the initial $n$ also counts).

The trajectory of the Collatz sequence: the number of operations and the highest point

Input

One positive integer $n$.

Output

One line with two integers separated by a space: the number of operations and the largest number.

Note

$1 \le n \le 10^{6}$

Examples

Input #1
6
Output #1
8 16
Input #2
1
Output #2
0 1

Sign in to submit a solution

Signing up is free and takes a minute.