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

how do presidential candidates get most of their money for preconvention campaigns?
When is secxtanx equal to 0
how can the excessive use of fertilizers affect biodiversity if it is washed into the river
PLEASE GUYS I REALLY NEED HELP ASAP. THIS IS SO IMPORTANT, I AM EVEN WILLING TO PAY FOR REAL. Summarize two observations that are contrary to the predictions b
S is the set of prime numbers that are less than 15
The total amount of living tissue within a given trophic level is called the?
A rope is cut into three pieces p,q, and r. the lengths of the pieces are in the ratio 3:5:7. if the rope is 33 feet 9 inches long, what are the lengths of p, q
What is output and input x or y
He immediately felt the sharp end of the gun what is the pronoun? And what Is the case? PLZ HELP ILL MARK YOU BRAINLIEST!
draw the structure of the isomer that have the molecular formula C5H11Br that is incapable of reacting by E2 mechanism