function nthFib(n) {
if(n <= 2) return n -1;
return nthFib(n - 2) + nthFib(n - 1);
}
function fibonacci(n) {
// write your solution here
let fibo = [0, 1]
for (var i = 2; i <= n; i++) {
fibo[i] = fibo[i - 1] + fibo[i - 2];
}
return fibo[n]
}
console.log(`fibonacci value at position 5: ${fibonacci(5)}`)