title: Greater Common Divisor/ Least Common Divisor for JavaScript
body: <p>I'm trying to figure out some issues for calculating the Least Common Multiple (LCM).</p>
  
  <p>In order to calculate GCD (for two or three numbers) I'm using two formulas:</p>
  
  <pre><code>gcdTwoNumbers:function(number1,number2){
  
      if(number2 == 0){
          return number1;
      }
  
      return this.gcdTwoNumbers(number2, number1 % number2);
  
  }
  </code></pre>
  
  <p><strong>and</strong></p>
  
  <pre><code>gcdThreeNumbers:function(number1, number2, number3){
  
    return this.gcdTwoNumbers(number1, this.gcdTwoNumbers(number2,number3));
  
  }
  </code></pre>
  
  <p>in order to calculate the LCM I'm calling the above functions for two or three numbers respectively:</p>
  
  <pre><code>      var lcm = randomNumber1 * randomNumber2  / (gcdTwoNumbers(randomNumber1,randomNumber2));
  </code></pre>
  
  <p><strong>and</strong></p>
  
  <pre><code>      var lcm = randomNumber1 * randomNumber2 * randomNumber3 / (gcdThreeNumbers(randomNumber1,randomNumber2,randomNumber3));
  </code></pre>
  
  <p>Calculations for two numbers is correct, but I get wrong results for the calculation of 3 numbers. Any suggestions/corrections are welcome.</p>