Skip to content

Instantly share code, notes, and snippets.

@gpDA
Created February 23, 2022 16:54
Show Gist options
  • Save gpDA/b5ca83cec62a08380dbb119dbf0a065f to your computer and use it in GitHub Desktop.
Save gpDA/b5ca83cec62a08380dbb119dbf0a065f to your computer and use it in GitHub Desktop.
const findFibonacci = (n) => {
if (n == 1) return [0, 1];
let res = findFibonacci(n-1);
res.push(res[res.length - 1] + res[res.length - 2])
return res;
}
console.log(findFibonacci(5)); // [0, 1, 1, 2, 3, 5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment