LearnPy Hub
← Loops problems
Medium

Collatz Steps

Start from n. If it is even, halve it; if odd, make it 3n + 1. Count the steps until you reach 1.

Input

One integer n ≥ 1.

Output

The number of steps.

Sample 1

Input
6
Output
8

Sample 2

Input
1
Output
0
solution.py
Output appears here
Collatz Steps · Python practice problem · LearnPy Hub