Question
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.
The range will be an array of two numbers that will not necessarily be in numerical order.
For example, if given 1 and 3, find the smallest common multiple of both 1 and 3 that is also evenly divisible by all numbers between 1 and 3. The answer here would be 6.
My Code So Far
function smallestCommons(arr) {
let newArr = [];
let changedArr = arr.sort((a, b)=>{
if(a>b){
return 1;
}
if(b>a){
return -1;
} else {
return 0;
}
})
for(let i = changedArr[0]; i < changedArr[1]; i++){
newArr.push(i);
}
let answer = changedArr.every((item)=>{
})
}
smallestCommons([1,5]);
My Question
- I was hoping you would be able to help me understand the question - I have looked into the lowest common multiple, but the 'evenly divisible' throws me off.
- I was hoping you could solve the problem, and break down the solution simply.
I am asking a lot, so if you answer it is greatly appreciated!