title: How to find the least common multiple of a range of numbers?
body: <p>Given an array of two numbers, let them define the start and end of a range of numbers.  For example, <code>[2,6]</code> means the range 2,3,4,5,6. I want to write javascript code to find the least common multiple for the range.  My code below works for small ranges only, not something like <code>[1,13]</code> (which is the range 1,2,3,4,5,6,7,8,9,10,11,12,13), which causes a stack overflow.  How can I efficiently find the least common multiple of a range?</p>
  
  <pre><code>function leastCommonMultiple(arr) {
      var minn, max;
      if ( arr[0] &gt; arr[1] ) {
          minn = arr[1];
          max = arr[0];
      } else {
          minn = arr[0];
          max = arr[1];
      }
      function repeatRecurse(min, max, scm) {
          if ( scm % min === 0 &amp;&amp; min &lt; max ) {
              return repeatRecurse(min+1, max, scm);
          } else if ( scm % min !== 0 &amp;&amp; min &lt; max ) {
              return repeatRecurse(minn, max, scm+max);
          }
          return scm;
      } 
      return repeatRecurse(minn, max, max);
  }
  </code></pre>