Ask Question
5 May, 23:51

Write a function gcd (x, y) that returns the greatest common divisor of the parameters candy. You can use the Euclidean algorithm, which uses the fact that gcd (x, y) = gcd (modx, x). Say you want to nd the gcd of 462 and 1071

+4
Answers (1)
  1. 6 May, 00:45
    0
    In some language, the function can be written recursively using the correct Euclidean algorithm as ...

    gcd[y_, x_] : = If[Mod[y, x]==0, x, gcd[x, Mod[y, x]]]

    Using this on the given numbers, you get ...

    gcd[462, 1071] = 21
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a function gcd (x, y) that returns the greatest common divisor of the parameters candy. You can use the Euclidean algorithm, which ...” in 📙 Mathematics if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers