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!! (LC)The bombing of the World Trade Center in New York City in 1993 was an example of the growth of which of the following issues at the end of the 20th c
The given graph represents the function f(x) = 2(5)x. How will the appearance of the graph change if the a value in the function is decreased, but remains great
Can someone help me please !???
choose the slope intercept form of 3x + 2y = 5
Which statement about presidential caucuses and primary elections is most accurate? O A. Participating in a caucus takes longer than voting in a primary, so vot
Which classification best represents a triangle with side lengths 10 in., 12 in., and 15 in.?
How many countries are in the world?
True or False. An ergometer is a device that accurately measures caloric expenditure.
Help me now.. Which cell organelle is primarily responsible for ATP synthesis
What is the answer to this question