Skip to content

Commit

Permalink
✨ Implement nth fibonacci
Browse files Browse the repository at this point in the history
  • Loading branch information
matssom committed Jun 16, 2021
1 parent cac1fa4 commit 2b9db7b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions js/easy/nth_fib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Get nth fibonacci number

function getNthFib(n) {
if (n === 1) return 0
if (n === 2) return 1
return getNthFib(n - 1) + getNthFib(n - 2)
}

0 comments on commit 2b9db7b

Please sign in to comment.