Python函数练习

怎么在collztz函数里判断collatz(x)是否等于1

img


img


def collatz(x):
    if x%2==0:
        if x/2 != 1:
            print(int(x/2))
            return collatz(x/2)
    else:
        if  3*x+1 != 1:
            print(int(3*x+1))
            return collatz(3*x+1)

collatz(10)