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

When something is heated, during the phase change, what happens to the temperature? volume? Mass? Average kinetic energy of the molecules? and the particle move
What do you thinkk the poeple are like in Silicon Valley?
Which of the four major regions of the United States was settled last by U.S. citizens
Which of the following is a logical prediction about the future of the united states? A:The united states will make a new advances in internet technology B:The
What are the measures of two complementary angles if the difference of their measures is 18°?
The Iliad uses in media res to build suspense and structure the story which best describes the structure
What was the result of the reconstruction amendments?
The commands available from a menu may change as a result of a users actions
What is m∠BCD? A) 52° B) 64° C) 104° D) 116°
NEED HELP ASAP: Solve the system of equations. 13x−y=90 y=x2−x−42 Enter your answers in the boxes.