← Problem book: C
Lesson 46 of 96 · 10 XP
The Collatz conjecture
Theory and problem statement
Machine translation, not yet reviewed by a native speaker.
Take a number n (n ≥ 1). If it is even, divide it by 2; if it is odd, multiply it by 3 and add 1.
Repeat until you get 1. Print how many steps it took.
Example
Input:
6
Output:
8
Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.