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

a museum has 50 pieces of art to display in an exhibit. of these, 11 are photos and 39 are color paintings. the manager wants to add more photos so they repre
Part a: If the diameter of a wheel is 1 yard, then it's radius is how many inches? Part b: write a statement telling how u know your solution to A is correct.
A number of two digits is such that twice the ten digit it is 6 greater than the unit digit. When the digits are reversed the number is increased by 9. Find the
The mean gas mileage for a hybrid car is 57mpg. Suppose that the gasoline mileage is approx normally distributed with a standard deviation of 3.5mpg. what propo
how many times does 5 go into 365
change 2.36 to a mixed number and reduced to lowest terms
Use scientific notation to perform 0.07x1600/0.0004
the cheerleaders are making a rectangular banner for a football game. the length of the banner is 30 ft long. the cheerleaders can use no more than 96 feet of t
What goals did the movement of the new left achieve?
what are the natural resources in south America?