Write a function that takes two numbers and returns their greatest common divisor (GCD).
function findGCD(number1, number2) { if(number2 === 0) { return number1; } return findGCD(number2, number1 % number2); } console.log(findGCD(-1, -5)); console.log(findGCD(19, 5)); console.log(findGCD(72, 81)); console.log(findGCD(14, 0));
> -1 > 1 > 9 > 14
The above is the detailed content of Find the Greatest Common Divisor. For more information, please follow other related articles on the PHP Chinese website!