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

What are the components of vector A if its magnitude is 70 m/s and makes an angle of 51.7° with the +x-axis? A. Ax = 53.6 m/s, Ay = 87.0 m/s B. Ax = 87.0 m/s,
What group of people served as the “study base” of the frontier?
Joan had 5 pitchers of water divided by her 8 plants. What fraction of a pitcher did each plant get?
interval notation, I need help with this and I can't figure out how to do it!!
I need help on this question
joe pitches for his baseball team twice a week. he trhows an avarege of 78 pitches a game. how many pitches did he throw in three weeks?
What strategy is a way to increase happiness? A; make good decisions B; limit chances of failur C; generate more income D; pay closer attention to you appea
I need help with algebra 2
ANSWER THIS QUESTION WITH A, B, C, D, or E
How does the constitution help address a problem that the United States was facing in 1789s?