Generation

generate functionMon, 14 Nov 2022

calculate the first 10 Fibonacci number with a parametrized function without recursion

function fibonacci(n) { let arr = [0, 1]; for (let i = 2; i < n + 1; i++) { arr.push(arr[i - 2] + arr[i - 1]); } return arr[n]; }

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant