logo CodeStepByStep logo

recursion_mystery_div2

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(n):
    if n <= 1:
        print(n, end="")
    else:
        mystery(n // 2)
        print(",", n, end="")
mystery(1)
mystery(2)
mystery(3)
mystery(4)
mystery(16)
mystery(30)
mystery(100)

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.