Skip to content

Instantly share code, notes, and snippets.

@YannMjl
Created July 15, 2019 19:08
Show Gist options
  • Save YannMjl/bae3cb9ee74b85ecb26c1feaf92f0b9d to your computer and use it in GitHub Desktop.
Save YannMjl/bae3cb9ee74b85ecb26c1feaf92f0b9d to your computer and use it in GitHub Desktop.
// recursive calculation of Fibonacci numbers
function fibonacci(number) {
if (number <= 1) return number;
return fibonacci(number - 2) + fibonacci(number - 1);
}
console.log(fibonacci(5));
console.log(fibonacci(6));
console.log(fibonacci(7));
// **********************************************************************************
// - In this case the run time of readArrayOfArray is quadratic: O(2^N)
// **********************************************************************************
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment