Ask Question
28 September, 08:48

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

+1
Answers (1)
  1. 28 September, 09:14
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers