ran npm run tdd & generated TDD
This commit is contained in:
7
test/fibonacciUntilNum/fibonacciUntilNum.js
Normal file
7
test/fibonacciUntilNum/fibonacciUntilNum.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = num => {
|
||||
let n = Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2));
|
||||
return Array.from({ length: n }).reduce(
|
||||
(acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),
|
||||
[]
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user