'use strict';

var gcd = require('./gcd.js');

/**
 * Algorithm to calculate Least Common Multiple based on Euclidean algorithm
 *
 * @param Number
 * @param Number
 *
 * @return Number
 */
var lcmDivisionBased = function (a, b) {
  if (a === 0 || b === 0) {
    return 0;
  }
  a = Math.abs(a);
  b = Math.abs(b);
  return a / gcd(a, b) * b;
};

/**
 * Algorithm to calculate Least Common Multiple based on Stein's Algorithm
 *
 * @param Number
 * @param Number
 *
 * @return Number
 */
var lcmBinaryIterative = function (a, b) {
  if (a === 0 || b === 0) {
    return 0;
  }
  a = Math.abs(a);
  b = Math.abs(b);
  return a / gcd.binary(a, b) * b;
};

lcmDivisionBased.binary = lcmBinaryIterative;
module.exports = lcmDivisionBased;

@@ -47,37 +47,26 @@
 %0A/**%0A * 
-Algorithm to c
+C
 alcul
-at
+e th
 e Least 
@@ -85,36 +85,60 @@
 ple 
-based on Euclidean algorithm
+with a given Greatest Common Denominator%0A * function
 %0A *%0A
@@ -163,32 +163,51 @@
 * @param Number%0A
+ * @param Function%0A
  *%0A * @return Nu
@@ -223,45 +223,52 @@
 var 
-lcmDivisionBased = function (
+genericLCM = function (gcdFunction, 
 a, b) %7B%0A
   if
@@ -255,32 +255,33 @@
 nction, a, b) %7B%0A
+ 
   if (a === 0 %7C%7C
@@ -364,16 +364,24 @@
  a / gcd
+Function
 (a, b) *
@@ -453,254 +453,509 @@
  on 
-Stein's Algorithm%0A *%0A * @param Number%0A * @param Number%0A *%0A * @return Number%0A */%0Avar lcmBinaryIterative = function (a, b) %7B%0A  if (a === 0 %7C%7C b === 0) %7B%0A    return 0;%0A  %7D%0A  a = Math.abs(a);%0A  b = Math.abs(b);%0A  return a / gcd.binary(a, b) * b;%0A%7D;%0A%0A
+Euclidean algorithm%0A * calls the generic LCM function passing the division based GCD calculator%0A *%0A * @param Number%0A * @param Number%0A *%0A * @return Number%0A */%0Avar lcmDivisionBased = genericLCM.bind(null, gcd);%0A%0A/**%0A * Algorithm to calculate Least Common Multiple based on Stein's Algorithm%0A * calls the generic LCM function passing the binary interative GCD calculator%0A *%0A * @param Number%0A * @param Number%0A *%0A * @return Number%0A */%0Avar lcmBinaryIterative = genericLCM.bind(null, gcd.binary);%0A%0Avar lcm = 
 lcmD
@@ -966,16 +966,21 @@
 ionBased
+;%0Alcm
 .binary 
@@ -1017,27 +1017,14 @@
 xports = lcm
-DivisionBased
 ;%0A

Remove duplicated code from LCM