题解 | 数字猜想
数字猜想
https://www.nowcoder.com/practice/87dd43076d40421ab7fd5bb92bc3f4e2
x = int(input())
ans = 0
while x != 1:
if x % 2 == 1:
x = x * 3 + 1
else:
x //= 2
ans += 1
print(ans)
数字猜想
https://www.nowcoder.com/practice/87dd43076d40421ab7fd5bb92bc3f4e2
x = int(input())
ans = 0
while x != 1:
if x % 2 == 1:
x = x * 3 + 1
else:
x //= 2
ans += 1
print(ans)
相关推荐