smallestCommons([1, 5]) should return 60

Isn’t the smallest common denominator between 1 and 5 is 5? How and why are they expecting 60 instead? Check out the link below. Without understanding what to return, I can’t tackle this problem…

Hi @NathanVu !

The key to understanding this problem is the first sentence.

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.

You can visualize it this way.

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

All of those numbers divide evenly which mean they all have a remainder of 0.

You can check by doing the math.

5 / 5 = 1
5 / 4 = 1.25 // this has a remainder other than zero.

If you run console.log(5%4) you will see a remainder of 1.

Your goal is to find the smallest common multiple for the range of numbers.

That means if you take a number like 60 and divide it by a range of numbers the results should all have a remainder of zero.

Hope that helps!

1 Like

WOW!! This is a lot harder than I thought. I’m googling on how the algorithm works hopefully I can translate this into javascript form. I’m near the end of the intermediate Algorithm challenge. Is it suppose to be this challenge? Very difficult!

Yeah, this is a tricky challenge. I recommend that people look up and implement the algorithms on Wikipedia for this problem. Researching and implementing algorithms is a pretty key skill in professional development.

1 Like