408746: GYM103294 A Journey Home

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Journey Hometime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Odysseus is trying to find his way home, after he got a little bit lost after going out on a journey. Sadly, he finds that he's struggling quite a bit, partly because some gods are upset at him. As it turns out, there are lots of locations in the world numbered by the positive integers, and the gods have decided the following rules for Odysseus's route. For simplicity, let us denote a location by the number it is at. If Odysseus's location $$$n$$$ is even, his next step will be location $$$\frac n2$$$. If Odysseus's location $$$n$$$ is odd, his next step will be location $$$3n + 1$$$. Now, given his starting location $$$s$$$, determine how many steps it will take for Odysseus to reach home, which is location $$$1$$$.

Input

A single integer $$$s (1 \le s \le 100)$$$, Odysseus' starting location.

Output

A single integer detailing the number of steps it takes to get home.

ExampleInput
3
Output
7
Note

Starting at location $$$3$$$, Odysseus will take the following path: $$$$$$3 \rightarrow 10 \rightarrow 5 \rightarrow 16 \rightarrow 8 \rightarrow 4 \rightarrow 2 \rightarrow 1$$$$$$ The path above is a total of $$$7$$$ steps.

加入题单

算法标签: