Skip to content

Commit 2bb330e

Browse files
Create FibonacciNumberRecursive.js (#380)
* Create FibonacciNumberRecursive.js * Update FibonacciNumberRecursive.js Co-authored-by: vinayak <itssvinayak@gmail.com>
1 parent 7a7cdd6 commit 2bb330e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Recursive/FibonacciNumberRecursive.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// https://en.wikipedia.org/wiki/Fibonacci_number
2+
3+
const fibonacci = (N) => {
4+
if (N === 0 || N === 1) return N
5+
6+
return fibonacci(N - 2) + fibonacci(N - 1)
7+
}
8+
9+
10+
// testing
11+
(() => {
12+
const number = 5
13+
console.log(number + 'th Fibonacci number is ' + fibonacci(number))
14+
})()

0 commit comments

Comments
 (0)