代码

# basic_1001.py

if __name__ == '__main__':
    n = int(input())
    step = 0

    while n != 1:
        if n % 2 == 0:
            n = n // 2
        else:
            n = (3 * n + 1) // 2
        step += 1

    print(step)

运行

input:
100
output:
18