Fibonacci Number
by arunoda
Babel + JSX
let ops = 0
function Fib(n) {
if (n < 2) return n
let n2 = 0
let n1 = 1
for (let i = 2; i < n; i++) {
ops ++
const total = n1 + n2;
n2 = n1
n1 = total
}
return n1 + n2
}
console.log(Fib(4), ops);