programming-examples/js/Recursion/Write a JavaScript program to find the greatest common divisor (gcd) of two positive numbers..js
2019-11-15 12:59:38 +01:00

8 lines
148 B
JavaScript

var gcd = function(a, b) {
if ( ! b) {
return a;
}
return gcd(b, a % b);
};
console.log(gcd(2154, 458));