logo CodeStepByStep logo

recursion_mystery_div10

Language/Type: Python recursion

For each call to the following recursive function, write the value that is returned.

def mystery(x, y):
    if x < 0:
        return -mystery(-x, y)
    elif y < 0:
        return -mystery(x, -y)
    elif x == 0 and y == 0:
        return 0
    else:
        return 100 * mystery(x // 10, y // 10) + 10 * (x % 10) + y % 10
mystery(5, 7)
mystery(12, 9)
mystery(-7, 4)
mystery(-23, -48)
mystery(128, 343)

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.