# Smallest Common Multiple - Recursion

**URL:** <https://forum.freecodecamp.org/t/smallest-common-multiple-recursion/142445>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [August 18, 2017, 6:53am UTC](https://forum.freecodecamp.org/t/smallest-common-multiple-recursion/142445 "2017-08-18T06:53:54Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ppc](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ppc/32/63349_2.png) [@ppc](https://forum.freecodecamp.org/u/ppc)\
**Post date:** [August 18, 2017, 4:06pm UTC](https://forum.freecodecamp.org/t/smallest-common-multiple-recursion/142445/2 "2017-08-18T16:06:21Z")

</div>

You may want to follow the discussion of LCM here

> [@Smallest Common Multiple Feedback](https://forum.freecodecamp.org/t/smallest-common-multiple-feedback/141961/4):
>
> I don’t think your solution is overcomplicated - there are some obvious simplifications like anything mod 1 is zero i.e. n % 1 === 0 is true for any integer n - also instead of two cases to handle the bigger of a pair of numbers you can first find the max and have just one case you have actually done a really great job of coding up the literal definition of lcm - the challenge now is to incrementally improve and refine your solution lcm is a pure math problem - specifically from number theory …

Here’s your solution in everyday language

> check each multiple of max for divisibility by all numbers in the range - the multiple is increased if divisibility fails - the number is decremented if divisibility succeeds

this hews well to the definition of LCM as the lowest common multiple

it is a brute force or exhaustive algorithm - it is slow for couple reasons - if the range is large e.g. 2-10 then each multiple has to be checked many times - if the numbers are large like 18-20 then many multiples of max are tried before hitting a common multiple

still it can work iteratively in a loop

but as implemented recursively above it simply will not work for even slightly large numbers because each new multiple increases the recursion depth and javascript quickly runs out of memory after a certain recursion depth

---

_[View the full topic](https://forum.freecodecamp.org/t/smallest-common-multiple-recursion/142445)._
