def showwork(fn):
    def better(*arg, **karg):
        print(fn.__name__, arg, karg)
        return fn(*arg, **karg)
    return better

def collatz(n : int) -> int:
    if n == 1: return n
    if n&1: return collatzodd(n)
    else: return collatzeven(n)

@showwork
def collatzodd(n : int) -> int:
    return collatz(3*n+1)

@showwork
def collatzeven(n : int) -> int:
    return collatz(n//2)

@showwork
def add(x,y): return x+y

print(collatz(340))
print(add(3,y=4))