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

$\begingroup$

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.

$\endgroup$ 7 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like