Here is the problem is known as Smallest Common Multiple.

According to the test case,

`smallestCommons([1, 5])`

should return 60.

What’s going with 1 and 5 that returns 60?

Here is the problem is known as Smallest Common Multiple.

According to the test case,

`smallestCommons([1, 5])`

should return 60.

What’s going with 1 and 5 that returns 60?

Hi!

Find the smallest common multiple of the provided parameters that can be evenly divided by both, as well as by all sequential numbers in the range between these parameters.

**by all sequential numbers in the range between these parameters**

So `smallestCommons([1,5])`

should find a smallest common multiple for the following numbers: `[1, 2, 3, 4, 5]`

Hope it explains your question

1 Like

In other words you have to find the smallest integer that will be divisible by all these numbers.

For `[1,5]`

this number is `60`

because:

```
60 / 5 = 12
60 / 4 = 15
60 / 3 = 20
60 / 2 = 30
60 / 1 = 60
```

1 Like

@sitek94 why it’s 60 not 20?

```
20 / 5 = 4
20 / 4 = 5
20 / 3 = 6.67
20 / 2 = 10
20 / 1 = 20
```

Is that for decimal point `20 / 3 = 6.67`

?

Smallest common multiple has to be a positive integer No decimals here

1 Like

@sitek94 my code solved [1,5] but others showing infinite loop

```
function smallestCommons(arr) {
let one = arr[0]
let two = arr[1];
let big;
let small;
if(one>two){
big = one;
small = two;
}else{
big = two;
small = one;
}
function check(num){
var cc = 0;
for(let i=small; i<=big; i++){
if(num%i === 0){
cc += 1;
}
}
if(cc === big){
return true;
}else{
return false;
}
}
let result;
var x = small;
for(let i=1; i<=x; i++){
if(check(i)){
result;
}else{
x += 1
}
}
console.log(x)
return arr;
}
```

Is my way of thinking good?

1 Like

For this one, a loop based solution can reach the correct answer, but it will be slow. I’d look at the Wikipedia articles for LCM and GCD.

1 Like