solving a function where [x mod y represents the remainder after division of x by y]

1.4k Views Asked by At

I would like help solving this practice question.

For a function f(x, y) defined below, what is the value of f(775, 527)? Here, x mod y represents the remainder after division of x by y.

f(x, y): if y = 0 then return x else return f(y, x mod y)


So it's saying x mod y represents 248?

Using the function definition, y does not equal 0 so that means I need to return f(y, x mod y).

775 mod 527 = 248

775 / 527 = 1 r248

f(527, 775 mod 527) -> f(527, 248) -> 527 mod 248 = 31

I was able to figure out the correct answer 31, however I don't see where it tells me 527, 248 should be solved as x mod y.