Tell us what’s happening:
The code locally runs fine and tests correctly with all test cases.
When run in the freeCodeCamp window, the last test fils.
I assume this is a precision issue, but don’t know how to solve it.
I would like to stick with the algorithms I came up with. How do I circumvent this rounding error?
Your code so far
function smallestMult(n) {
let smallest = n;
while (! evenly_div(smallest, n)){
smallest += n;
}
return smallest;
}
function evenly_div(x, a) {
for (let i = 1; i < a; i++) {
if ( x % i != 0) {
return false;
}
}
return true;
}
console.log(smallestMult(5));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15
.
Link to the challenge:
https://learn.freecodecamp.org/coding-interview-prep/project-euler/problem-5-smallest-multiple