Hi,
I can’t figure out what is wrong with my code. I would appreciate any kind of help.
function smallestCommons(arr) {
var lcm = 1;
function get_gcd(a,b){
var g = Array.from(arguments).sort(function(a,b){
return a - b;
});
if (g[0] === 0){
return g[1];
}
else {
return get_gcd(g[0], g[1] % g[0]);
}
}
function get_lcm(a,b){
lcm = (a * b) /get_gcd(a,b);
}
var h = Array.from(arr).sort(function(a,b){
return a - b;
});
for (var s = 0; h[0]+s <= h[1]; s++){
return get_lcm(h[0]+s, lcm);
}
return lcm;
}
smallestCommons([1,5]);