I am pretty stuck here.
I understand what the problem is asking for: return a single number that is divisible by all the numbers within a range. So if the range is 1 to 7 then the number we want to return should be divisible by 1,2,3,4,5,6, and 7.
After reading up on Euclidean math (which I did not understand) and this little nifty mathematical trick for finding LCM, I am NO closer to understanding how to code for this.
So I caved and looked at the Basic Solution. But I am at a loss as to what the do...while
loop is doing. Especially this line: quot = newArr[0] * loop * newArr[1];
I’ve read the explanation several times and it does not shed any light, at last not for me.
Can anyone help me understand they WHY behind the Basic Solution?
Thank you.
Your code so far
function smallestCommons(arr) {
return arr;
}
smallestCommons([1,5]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/smallest-common-multiple