Fibonacci Recursion

Run Settings
LanguageJavaScript
Language Version
Run Command
const fibonacciRecursion = (n)=>{ if(n == 1) return 1; if(n == 2) return 1; return fibonacciRecursion(n-1)+fibonacciRecursion(n-2); } const fibonacciIterative = (n)=>{ let arr = []; arr[0] = 1; arr[1] = 1; for(let i=2; i<=n;i++) { arr[i] = arr[i-1]+arr[i-2]; } return arr; } console.log(fibonacciRecursion(8)); console.log(fibonacciIterative(7));
Editor Settings
Theme
Key bindings
Full width
Lines