fix snippets/arrayLcm part syntax

This commit is contained in:
lucky4
2017-12-23 08:19:04 +08:00
parent 0ff05e5f6a
commit 3cc1cd50c2
2 changed files with 2 additions and 2 deletions

View File

@ -290,7 +290,7 @@ Use `Array.reduce()` and the `lcm` formula (uses recursion) to calculate the low
```js ```js
const arrayLcm = arr =>{ const arrayLcm = arr =>{
const gcd = (x, y) => !y ? x : gcd(y, x % y); const gcd = (x, y) => !y ? x : gcd(y, x % y);
const lcm = (x, y) => (x*y)/gcd(x, y); const lcm = (x, y) => (x*y)/gcd(x, y)
return arr.reduce((a,b) => lcm(a,b)); return arr.reduce((a,b) => lcm(a,b));
} }
// arrayLcm([1,2,3,4,5]) -> 60 // arrayLcm([1,2,3,4,5]) -> 60

View File

@ -7,7 +7,7 @@ Use `Array.reduce()` and the `lcm` formula (uses recursion) to calculate the low
```js ```js
const arrayLcm = arr =>{ const arrayLcm = arr =>{
const gcd = (x, y) => !y ? x : gcd(y, x % y); const gcd = (x, y) => !y ? x : gcd(y, x % y);
const lcm = (x, y) => (x*y)/gcd(x, y) const lcm = (x, y) => (x*y)/gcd(x, y);
return arr.reduce((a,b) => lcm(a,b)); return arr.reduce((a,b) => lcm(a,b));
} }
// arrayLcm([1,2,3,4,5]) -> 60 // arrayLcm([1,2,3,4,5]) -> 60