JSFiddle - React, Tailwind, and code Playground

by hlmurray91

HTML

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?

Babel + JSX

const divisible = () => {
	let i = 2520;
  let smallestNum = false;
  
  while (!smallestNum) {
  	i += 1;
    let isDividable = true;
    
    for (var j = 2; j <= 20; j++) {
    	if (i % j !== 0) {
      	isDividable = false;
        break;
      }
    }
    
    if (isDividable) {
    	smallestNum = true;
    }
  }
  
  return i;
};

console.log(divisible());