2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
Feel like I went about this the wrong way, but my gut said to check if a number divided evenly by each number up to 20 and when it did, return it.
function isDivisible(number) {
for (d = 1; d <=20; d++) {
if (number % d === 0) {
continue;
} else {
return false;
}
}
return true;
}
var number = 1;
do {
number++;
} while (! isDivisible(number));
console.log(number);