re: Project Euler #5 - Finding the Smallest Multiple VIEW POST

FULL DISCUSSION
 

Here is my solution. it's not the cleanest but is quite fast and it seems to work. I used nodeJS

function checkDivisible(number) {
  if (
    number % 20 == 0 &&
    number % 19 == 0 &&
    number % 18 == 0 &&
    number % 17 == 0 &&
    number % 16 == 0 &&
    number % 15 == 0 &&
    number % 14 == 0 &&
    number % 13 == 0 &&
    number % 12 == 0 &&
    number % 11 == 0 &&
    number % 10 == 0 &&
    number % 9 == 0 &&
    number % 8 == 0 &&
    number % 7 == 0 &&
    number % 6 == 0 &&
    number % 5 == 0 &&
    number % 4 == 0 &&
    number % 3 == 0 &&
    number % 2 == 0 &&
    number % 1 == 0
  ) {
    return true;
  } else {
    return false;
  }
}

function main() {
  let done = false;
  let c = 1;
  console.log(`c = ${c}, incrment = ${c}`);
  let startTime = Date.now();
  while (!done) {
    if (checkDivisible(c)) {
      console.log(`${c} is Divisible by 1 - 20 with no remainder`);
      done = true;
    }
    c++;
  }
  let endTime = Date.now();
  console.log(`Time Taken: ${Math.round(endTime - startTime)}ms`);
}
main();

here is the output

c = 1, incrment = 1
232792560 is Divisible by 1 - 20 with no remainder
Time Taken: 607ms
code of conduct - report abuse