logo CodeStepByStep logo

recursion_mystery_comma

Language/Type: Python recursion

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

def mystery(x, y):
    if y == 1:
        print(x, end="")
    else:
        print((x * y), end=", ")
        mystery(x, y - 1)
        print(",", (x * y), end="")
mystery(4, 1)
mystery(4, 2)
mystery(8, 2)
mystery(4, 3)
mystery(3, 4)

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.