Travis build: 907

This commit is contained in:
Travis CI
2018-01-03 11:52:32 +00:00
parent 7eb1a1e5e4
commit d1fb09d065
4 changed files with 46 additions and 8 deletions

View File

@ -7,14 +7,16 @@ Use `Array.from()`, `Math.log()` and `Math.floor()` to create an array of the de
Omit the second argument, `start`, to use a default value of `1`.
Omit the third argument, `step`, to use a default value of `2`.
``` js
const geometricProgression = (end, start = 1,step = 2) =>
Array.from({ length:Math.floor(Math.log(end/start)/Math.log(step))+1}).map((v, i) => start * (step ** (i)) )
```js
const geometricProgression = (end, start = 1, step = 2) =>
Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map(
(v, i) => start * step ** i
);
```
```js
geometricProgression(256); // [1, 2, 4, 8, 16, 32, 64, 128, 256]
geometricProgression(256,3); //[3, 6, 12, 24, 48, 96, 192]
geometricProgression(256,1,4); //[1, 4, 16, 64, 256]
geometricProgression(256,2,1); //Gives error
geometricProgression(256, 3); //[3, 6, 12, 24, 48, 96, 192]
geometricProgression(256, 1, 4); //[1, 4, 16, 64, 256]
geometricProgression(256, 2, 1); //Gives error
```