function fib(n) {
if(n === 0) return 0;
if(n <= 2) return 1;
let x = 1, y = 2;
for(let i = 3; i < n; i++) {
let oldX = x;
x = y;
y = y + oldX; /*?.*/
}
return y;
}
Categories
function fib(n) {
if(n === 0) return 0;
if(n <= 2) return 1;
let x = 1, y = 2;
for(let i = 3; i < n; i++) {
let oldX = x;
x = y;
y = y + oldX; /*?.*/
}
return y;
}