Skip to content

Commit 2250c0b

Browse files
committed
Completed nFibonacci in recursion.js
1 parent 3f0cdb6 commit 2250c0b

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎src/recursion.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
const nFibonacci = (n) => {
44
// fibonacci sequence: 1 1 2 3 5 8 13 ...
55
// return the nth number in the sequence
6+
7+
if (n <= 2) return 1;
8+
return nFibonacci(n - 1) + nFibonacci(n - 2);
69
};
710

811
const nFactorial = (n) => {

0 commit comments

Comments
 (0)