logo CodeStepByStep logo

recursion_mystery10

Language/Type: Python recursion

For each call to the following recursive function, write the output that is produced as it would appear on the console.

def recursion_mystery10(x):
    print(x, end=" ")
    if x <= 1:
        print("END ", end="")
    elif x % 2 == 0:
        recursion_mystery10(x // 2)
        print("+ ", end="")
    else:
        print("[ ", end="")
        recursion_mystery10(3 * x + 1)
        print("] ", end="")
recursion_mystery10(1)
recursion_mystery10(4)
recursion_mystery10(3)

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.