logo CodeStepByStep logo

recursion_mystery1

Language/Type: Python recursion

For each of the calls to the following recursive function below, indicate what output is produced:

def recursion_mystery1(x, y):
    if y <= 0:
        print("0 ", end="")
    elif x > y:
        print(x, end=" ")
        recursion_mystery1(x - y, y)
    else:
        recursion_mystery1(x, y - x)
        print(y, end=" ")
recursion_mystery1(6, 3)
recursion_mystery1(2, 3)
recursion_mystery1(5, 8)
recursion_mystery1(21, 12)
recursion_mystery1(3, 10)

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.