SIGN IN SIGN UP

Algorithms and Data Structures implemented in JavaScript for beginners, following best practices.

34087 0 0 JavaScript
/**
2021-11-28 11:49:11 +05:30
* @function Fibonacci
* @description Function to return the N-th Fibonacci number.
* @param {Integer} n - The input integer
* @return {Integer} - Return the N-th Fibonacci number
* @see [Fibonacci](https://en.wikipedia.org/wiki/Fibonacci_number)
*/
2021-11-28 11:49:11 +05:30
const fibonacci = (n) => {
if (n < 2) {
return n
}
2021-11-28 11:49:11 +05:30
return fibonacci(n - 2) + fibonacci(n - 1)
}
2021-11-28 11:49:11 +05:30
export { fibonacci }