Hi all,
I have one problem with Smallest Common Multiple in Intermediate Algorithm Scripting. I developed code, which I tried to run on my local machine and logged results to chrome browser’s console and results are correct - my code works. But still I can’t pass these two challenges:
smallestCommons([1, 13]) should return 360360.
smallestCommons([23, 18]) should return 6056820.
As I said, on my local it returns correct values but still I have cross for these two. So I am thinking it is maybe bug or something?
Here is my code:
function smallestCommons(arr) {
let max = Math.max(...arr);
let min = Math.min(...arr);
var number = 1;
while(true){
for(var i = min; i <= max; i++){
if(number % i != 0){
break;
}
if(i === max){
return number;
}
}
number++;
}
}
smallestCommons([1,13]);
Thanks for any feedback and wish you good day!