logo CodeStepByStep logo

while_mystery_3

Language/Type: Python loops

Given the following function, write the value returned by each of the following calls.

def mystery(x, y):
    while x != 0 and y != 0:
        if x < y:
            y -= x
        else:
            x -= y
    return x + y
mystery(3, 3)
mystery(5, 3)
mystery(2, 6)
mystery(12, 18)
mystery(30, 75)

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.