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

~/algor $ cat problems/if-juft-bolsa-yarmi

Half if even

Easy 1000 ms 64 MB 15%
Share

A positive integer $n$ is given. If $n$ is even, divide it by $2$; if it is odd, replace it with $3 * n + 1$. Find the resulting number.

An even number is halved, an odd number is replaced

Input

One positive integer $n$.

Output

One integer — the result.

Note

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

Examples

Input #1
6
Output #1
3
Input #2
7
Output #2
22

Sign in to submit a solution

Signing up is free and takes a minute.