你好,代码供参考:
n = int(input("n=")) while(n!=1): if(n%2==0): n/=2 else: n*=3 n+=1 print(int(n),end=' ')
结果:
n=10 5 16 8 4 2 1
如有帮助,还望给个采纳支持一下