google around the subject, and you’ll find that the smallest common multiple of A & B is equal to A times B divided by the greatest common divisor of A&B.
eg, A=4, b=10, the greatest common divisor of A&B = 2, so 4*10/2=20.
for finding the least common multiple of a series A, B, C, D, you can start with the first two, then repeat the process with the results against C, then the results of that against D.
function smallestCommons(arr) {
var maxValue = Math.max(...arr);
var minValue = Math.min(...arr);
var arr2 = [];
for (var i = minValue; i <= maxValue; i++) arr2.push(i);
var higestValueTable = 0;
function commonMultiple(value) {
return (higestValueTable % value === 0);
}
var countTable = 1;
var commonValue = 0;
while (true) {
higestValueTable = maxValue * countTable;
countTable++;
if (arr2.every(commonMultiple)) {
commonValue = higestValueTable;
break;
}
}
return higestValueTable;
}
smallestCommons([23,18]);