Smallest Common Multiple - need some help

Smallest Common Multiple - need some help
0

#1

Hi friends! Here is my code:

function smallestCommons(arr) {
arr.sort(function(a, b){
return b - a;
});

var min = arr[1],
max = arr[0],
newArr = [],
answ;

for(max; max >= min; max-- ){
newArr.push(max);
}

Multiple: for(var multpl = 1; multpl < 100000000; multpl++){

           answ = newArr[0] * multpl * newArr[1];

            for(var i=0; i<newArr.length; i++){
              
                if(answ % newArr[i] !== 0) {   
                      continue Multiple;
                  }
              }
        return answ;
      } 

}

I cheated using just number 100000000 in line " Multiple: for(var multpl = 1; multpl < 100000000; multpl++)".
Can you suggest variable instead of number 100000000 ?


#2

How about:

Multiple: for(var multpl = 1; ; multpl++){
...

#3

Oh! Thanks, I didn’t know if it is correct just skip this condition.