Skip to content

Instantly share code, notes, and snippets.

@ajrob
Last active August 29, 2015 14:02
Show Gist options
  • Save ajrob/81866bc9735394ab0b8d to your computer and use it in GitHub Desktop.
Save ajrob/81866bc9735394ab0b8d to your computer and use it in GitHub Desktop.
Euler Project Problem 5
// 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?
var smallestNumber = 19;
var uDone = false;
while (!uDone) {
smallestNumber++;
for (var i = 1; i <= 20; i++){
if(!isDivisible(i, smallestNumber)){
break;
}
if( i == 20){
uDone = true;
}
}
}
console.log(smallestNumber);
function isDivisible(divisor, dividend){
if(dividend%divisor === 0){
return true;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment