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

Which cell structure is most affected by this lack of energy
A sandbox has a perimeter of 21 1/2 feet. If the length is 5 1/4 feet, what is the area of the sand box?
in some regions of argentina, what is the name of the herbal tea shared among friends and relatives as a sign of friendship and acceptance
What elements of a speech should be adapted based on audience analysis?
I need help I keep getting either the answer b c or d Please know the right answer
This table shows the size, in acres, of four large water parks. What is the median of the sizes of the four water parks? Park Size (in Acres) A 66 B
Jake and Maddie each take the closest path from their homes to the store. Based on the picture below, what is the approximate difference in the distance each pe
Find the inverse of the given function.
Forgot the name of the game that you play a super soldier and fight robot which is third person
please help!!! Determine the area of the archway with a semicircle top arch and two rectangular pillars. The lower supports are _____ and the area of the two su