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
PostgreSQLv16

Her vises resultatet af din kode

Visible tests
1
Input
1
Expected0
2
Input
16
Expected4
3
Input
12
Expected9
4
Input
1000000
Expected152
5
Input
15
Expected17
6
Input
7
Expected16
Focus radio
Paused · SomaFM · Fluid