Smallest Common Multiple conditions

Smallest Common Multiple conditions
0.0 0

#1

Tell us what’s happening:

I don’t understand why the smallest Commons should return 60 instead of 5.

Your code so far

function smallestCommons(arr) {
  var arr1 = [];
  var arr2 = [];
  for(var i=1; i<20;i++) {
    arr1.push(i*arr[0]);
    arr2.push(i*arr[1]);
  }
  for(var s=0; s<arr1.length;s++) {
    if(arr1[s]%arr[1]==0)
      return arr1[s];
  }
  return undefined;
}


smallestCommons([1,5]);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0.

Link to the challenge:


#2

Find the smallest common multiple of the provided parameters that can be evenly divided by both, as well as by all sequential numbers in the range between these parameters.

It isn’t the smallest common multiple of 1 and 5, it’s the smallest common multiple of all numbers in the range 1-5. It’s the smallest common multiple of 1, 2, 3, 4, and 5.


#3

so 60 would be divisble by 1,2,3,4,5?


#4

Yes. It’s the smallest number that is divisible by all 5 of those numbers.


#5

ok thx for helping me out