Edited fibonacci.js
Added another possible solution that doesn't use a loop.
This commit is contained in:
parent
01aace24b1
commit
0d7c05485b
|
@ -10,4 +10,15 @@ const fibonacci = function(count) {
|
|||
return b;
|
||||
};
|
||||
|
||||
/* Another possible solution
|
||||
|
||||
const fibonacci = function(num) {
|
||||
const goldenRatio = (1 + Math.sqrt(5)) / 2;
|
||||
if(num < 0) return "OOPS";
|
||||
return Math.floor((goldenRatio**num) / Math.sqrt(5) + 0.5);
|
||||
}
|
||||
*/
|
||||
module.exports = fibonacci
|
||||
|
||||
|
||||
module.exports = fibonacci;
|
||||
|
|
Loading…
Reference in New Issue