Collatz Steps
The Collatz conjecture works like a number game where you keep applying one of two rules. The function steps receives a positive integer number and counts how many steps it takes to reach 1. If the number is even, divide it by 2; if it is odd, multiply it by 3 and add 1.
Примеры
Ввод
1Вывод
0Ввод
16Вывод
4Ввод
12Вывод
9Нужно реализовать
def steps(number: int) -> int:
Теги
math
Συνδεθείτε για να δείτε το ιστορικό υποβολών
ΣύνδεσηΣυνδεθείτε για να χρησιμοποιήσετε τον AI Mentor
ΣύνδεσηVisible tests
1
Input
1Expected
02
Input
16Expected
43
Input
12Expected
94
Input
1000000Expected
1525
Input
15Expected
176
Input
7Expected
16Focus radio
Paused · SomaFM · Fluid