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
Влез, за да видиш историята на решенията
ВходВлез, за да използваш ИИ ментора
ВходTests12
Visible tests
Скрит тест 7
Скрит тест 8
Скрит тест 9
Скрит тест 10
Скрит тест 11
Скрит тест 12
They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.
Focus radio
Paused · SomaFM · Fluid