-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem5.js
More file actions
27 lines (23 loc) · 813 Bytes
/
problem5.js
File metadata and controls
27 lines (23 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//
//set a high limit within the function the result will likely be less than.
//setting variable bool to true for each value, you can then write another for loop with a condition
//knowing that every statement will return false, therefor setting bool to false.
//if 'bool' is still true on a value from the first loop, after ran through the second for statement,
//that value will be the first value that passed the test, which is the smallest divisible from
//each number between 1..number.
function smallest(num){
for(var y=num+1; y<10000000000;y++){
var bool = true;
for(var x = 1; x<=num; x++){
if(y%x!==0){
bool = false;
break;
}
}
if(bool){
return y;
}
}
}
smallest(20);
//=> 232792560