My solution works in repl.it but it takes a bit to get there. How do I turn off infinite loop protections?
figured it out.
//noprotect
At the begining of the solution
Needed this for the least common multiplier one.
If your curious about my solution, here it is. Warning for spoilers.
//noprotect
function smallestCommons(arr) {
done = false;
index = Math.max(...arr);
do {
done = true;
for(var i = Math.min(...arr); i < Math.max(...arr); i++){
if(index % i != 0){
console.log(index + ' is not the smallestCommon');
done = false;
index += Math.max(...arr);
break;
}
}
} while(!done);
console.log(index + ' is the smallestCommon');
return index;
}
smallestCommons([1, 5]);
If you want to challenge yourself, there are efficient enough solutions that you don’t need to turn the protection off.