I already know how to find the GCD with no methods (below), but how can I create a function that will do it with either two or more integers?
function greatest(x,y){
return x<0 || y<0 ? null : x%y===0 ? y : greatest(y, x%y);
}
console.log(greatest(64,2)); //2
console.log(greatest(88,200)); //8
//Finding the gcd of two integers using recursion
const gcd = function(x, y) {
if (!y){ //if y is zero return back x
return x;
}
return gcd(y, x % y);
}