def collatz(number):
if number % 2 == 0:
# 偶数
# 打印出number // 2,并返回该值。
print(number//2)
return number // 2
else:
# 奇数
# 打印并返回3 * number + 1。
print(number*3 +1)
return number * 3 + 1
num_return = 0
while num_return == 0:
str_input = input('input:')
try:
num_input = int(str_input)
num_return= collatz(int(num_input))
if num_return == 1:
break
else:
num_return =0
except ValueError:
print('请输入数值')