1001 害死人不偿命的(3n+1)猜想 python实现

import sys


class Test:
    num = 0
    count = 0

    def __init__(self, n):
        self.num = n

    def Calculate(self):
        if self.num == 1:
            print(self.count)
            return 0
        elif self.num % 2 == 0:
            self.count += 1
            self.num /= 2
        else:
            self.count += 1
            self.num = int((3 * self.num + 1) / 2)
        self.Calculate()


num = int(input())
test = Test(num).Calculate()
上一篇:重新点亮linux 命令树————用户和用户组的配置文件[八]


下一篇:fawef