chanellhuntley6785 chanellhuntley6785
  • 25-11-2020
  • Computers and Technology
contestada

Write a function gcd(x, y) that returns the greatest common divisor of the parameters x and y. Use the Euclidean algorithm to do this. Return None if the gcd does not exist(i.e., if both parameters are 0)

Respuesta :

tonb
tonb tonb
  • 25-11-2020

Answer:

function gcd(x,y) {

if (!y && !x) return 'None';

if (!y) return x;

return gcd(y, x%y);

}

console.log(gcd(462, 910));

console.log(gcd(0, 0));

console.log(gcd(32, 40));

Explanation:

This example is in javascript.

Answer Link

Otras preguntas

help fast plz jdkdvehdk​
Please answer this correctly
Thallium-210 has a half-life of 1.32 minutes. Find an equation for the percent of Thallium-210 sample that remains after t minutes.
Standard cuts of beef, veal, pork, and lamb are called A. offal. B. saddles. C. flanks. D. primals.
Normalmente yo (preferir) enter answer tocar la guitarra. Me (gustar) enter answer la música clásica.
2 megabyte contain to byte​
Visualization and categorization work well for visual learners. Is this a technique you think benefits you as a learner? Why or why not?
help fast plz thank u all ​
help fast plz sjeofpnfv​
write an equation of the line that passes through (2, -3) and is perpendicular to the line y=-2x-3