I subsequently realized there is an efficient simple algorithm utilizing properties of the Greatest Common Divisor, as I noted here. Reproduced:
- Write a Greatest Common Divisor function
- Note that the Smallest Common Multiple (SCM) of any two numbers a and b is the value:
a * b / GCD(a,b).
- Calculate the SCM for the first two numbers of the range; then successively calculate the SCM for that value plus the next value in the range until you hit the end of the range.
I suggest that the challenge be:
- Immediately preceded by a Write a GCD function challenge;
- Be pre-populated with the GCD function just written by the student; and
- Be supplemented with my algorithm note above (or at least the comment
Note that the Smallest Common Multiple (SCM) of any two numbers a and b is the value:
a * b / GCD(a,b)
I believe this would be far more valuable to students than the existing challenge structure.