From 43ba1e0bccb05fa1564b9779f0c779a81f8cd81a Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 29 Dec 2017 14:56:07 +0000 Subject: [PATCH] Travis build: 626 --- README.md | 7 +++---- docs/index.html | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1e379163e..112aa68c6 100644 --- a/README.md +++ b/README.md @@ -2546,17 +2546,16 @@ isPrime(12); // false ### lcm -Returns the least common multiple of two or numbers/arrays. +Returns the least common multiple of two or more numbers/arrays. Use the greatest common divisor (GCD) formula and `Math.abs()` to determine the least common multiple. The GCD formula uses recursion. ```js const lcm = (...arr) => { - let data = [].concat(...arr); const gcd = (x, y) => (!y ? x : gcd(y, x % y)); - const helperLcm = (x, y) => x * y / gcd(x, y); - return arr.reduce((a, b) => helperLcm(a, b)); + const _lcm = (x, y) => x * y / gcd(x, y); + return [].concat(...arr).reduce((a, b) => _lcm(a, b)); }; ``` diff --git a/docs/index.html b/docs/index.html index f2133ab4f..a45295e6e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -482,11 +482,10 @@ isArmstrongNumber(56); // false };
isPrime(11); // true
 isPrime(12); // false
-

lcm

Returns the least common multiple of two or numbers/arrays.

Use the greatest common divisor (GCD) formula and Math.abs() to determine the least common multiple. The GCD formula uses recursion.

const lcm = (...arr) => {
-  let data = [].concat(...arr);
+

lcm

Returns the least common multiple of two or more numbers/arrays.

Use the greatest common divisor (GCD) formula and Math.abs() to determine the least common multiple. The GCD formula uses recursion.

const lcm = (...arr) => {
   const gcd = (x, y) => (!y ? x : gcd(y, x % y));
-  const helperLcm = (x, y) => x * y / gcd(x, y);
-  return arr.reduce((a, b) => helperLcm(a, b));
+  const _lcm = (x, y) => x * y / gcd(x, y);
+  return [].concat(...arr).reduce((a, b) => _lcm(a, b));
 };
 
lcm(12, 7); // 84
 lcm([1, 3, 4], 5); // 60