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

. Rewrite the following sentences in Spanish and replace the direct object and indirect object with the appropriate pronouns. Remember that these are informal c
Do the angle measurements 70, 90, 75 make a triangle?
. FAST What do you do when you proofread a peer’s report? A, look for little mistakes that make the report hard to read B, suggest other ways to organize ideas
What type of peer pressure is Sulima using? A. put down B. rejection C. reasoning
Postmodernism has been described as _____. Group of answer choices radical environmentalism radical rationalism radical relativism radical materialism
| What actions did Herbert Hoover take in order to fix the economic crisis of the 1930s?
Find the value of z.
Ms.Mendoza's monthly income was increased by 15%. If her salary last month was 10,000,how much is her salary now​
What was the name of alexander the great’s beloved warhorse?.
A data set with a smaller MAD has______than a data set with a larger MAD brainly A. a larger mean B. more variability C. more data D. less variability