logo CodeStepByStep logo

recursion_mystery3

Language/Type: Python recursion

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

def recursion_mystery3(n):
    if n < 0:
        return -recursion_mystery3(-n)
    elif n < 10:
        return (n + 1) % 10
    else:
        return 100 * recursion_mystery3(n // 10) + (n + 1) % 10
recursion_mystery3(7)
recursion_mystery3(42)
recursion_mystery3(385)
recursion_mystery3(-790)
recursion_mystery3(89294)

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.