Tell us what’s happening:
Describe your issue in detail here.
My question was “What is the smallest positive number that is evenly divisible by all of the numbers from 1 to n?”
My code is simple I create a array to store all number from 1 to n and then I use ‘every’ method to test the condition.
it works well for all the numbers except 20! why?
**Your code so far**
function smallestMult(n) {
let arr=[];
let c=0;
for(let a=1;a<=n;a++){
arr.push(a);
}
//console.log(arr);
const divisible_test=(x)=>n%x==0;
while(c==0){
if(arr.every(divisible_test)){
c=1;
console.log(n)
return n;
}
n++;
}
}
smallestMult(5);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36
Challenge: Problem 5: Smallest multiple
Link to the challenge: