Skip to content

Commit 8df33c9

Browse files
committed
Add Fibonacci problem variant
1 parent a97fc40 commit 8df33c9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const NthFibonacciNumber = (n) => {
2+
root_five = Math.sqrt(5);
3+
major_term = (1 + root_five) / 2;
4+
minor_term = (1 - root_five) / 2;
5+
6+
return Math.round(
7+
(1 / root_five) * (Math.pow(major_term, n) - Math.pow(minor_term, n))
8+
);
9+
};
10+
11+
module.exports = NthFibonacciNumber;

0 commit comments

Comments
 (0)