题解 | #魔法数字变换#
魔法数字变换
http://www.nowcoder.com/practice/db41a6ce80a646aa9a5eb6252ac2df76
n = int(input())
cnt = 0
while n != 1:
if n % 2 == 0:
n = n // 2
cnt += 1
else:
n = 3*n+1
cnt += 1
print(cnt)
魔法数字变换
http://www.nowcoder.com/practice/db41a6ce80a646aa9a5eb6252ac2df76
n = int(input())
cnt = 0
while n != 1:
if n % 2 == 0:
n = n // 2
cnt += 1
else:
n = 3*n+1
cnt += 1
print(cnt)
相关推荐