def collatz(number): if number%2==0: return number//2 if number%2==1: return 3*number+1 try: c=input("请输入一个数:") c=int(c) except: print("error!") print(collatz(c))
python函数
原文:https://www.cnblogs.com/hainabaichuan/p/11816251.html