def collatz(number): if number % 2 == 0: print(number // 2) return number // 2 elif number % 2 == 1: result = 3 * number + 1 print(result) return resultn = input("Give me a number: ")while n != 1: n = collatz(int(n))
输出:
Give me a number: 3105168421Give me a number: 1134175226134020105168421
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)