Merge branch 'master' of https://github.com/kriadmin/30-seconds-of-code
This commit is contained in:
@ -5,6 +5,6 @@ Returns the minimum value in an array.
|
||||
Use `Math.min()` combined with the spread operator (`...`) to get the minimum value in the array.
|
||||
|
||||
```js
|
||||
const arrayMin = zzarr => Math.min(...arr);
|
||||
const arrayMin = arr => Math.min(...arr);
|
||||
// arrayMin([10, 1, 5]) -> 1
|
||||
```
|
||||
|
||||
@ -10,5 +10,5 @@ const fibonacciTillNum = num => {
|
||||
let n = Math.ceil(Math.log(num * Math.sqrt(5) + 1/2) / Math.log((Math.sqrt(5)+1)/2))// fibonacci(5) -> [0,1,1,2,3];
|
||||
return Array.from({ length: n}).reduce((acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), []);
|
||||
}
|
||||
\\ fibsTillNum(15) -> [0,1,1,2,3,5,8,13]
|
||||
```
|
||||
// fibsTillNum(15) -> [0,1,1,2,3,5,8,13]
|
||||
```
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
### fibsTillNum
|
||||
|
||||
Returns the number of fibonnacci numbers till num(0 and num inclusive)
|
||||
Returns the number of fibonnacci numbers till num(0 and num inclusive).
|
||||
|
||||
```js
|
||||
const fibsTillNum = num =>
|
||||
Math.ceil(Math.log(num * Math.sqrt(5) + 1/2) / Math.log((Math.sqrt(5)+1)/2))// fibonacci(5) -> [0,1,1,2,3]
|
||||
\\ fibsTillNum(10) -> 7
|
||||
Math.ceil(Math.log(num * Math.sqrt(5) + 1/2) / Math.log((Math.sqrt(5)+1)/2))
|
||||
// fibonacci(5) -> [0,1,1,2,3]
|
||||
// fibsTillNum(10) -> 7
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user