Practice · 3 of 6
Reduce to One
CHALLENGE
Difficulty: beginner+25 XP
**Description:** Start from n. One step: if n is even, n becomes n/2;
otherwise n becomes 3n+1. Count the steps until n becomes 1.
**Input:** One integer n (1 ≤ n ≤ 10^6).
**Output:** One integer — the number of steps.
**Example:** 6 → 6→3→10→5→16→8→4→2→1 → 8 steps.
Press Submit to check your solution.
Back to lesson: Practice: Loop Patterns Set