challenge-algorithms-v2.0-w.../04-fibonacci/index.js

16 lines
206 B
JavaScript

export function fibonacci(value) {
var a = 0, b = 1;
if(value === 0){
return a;
}
for (var i = 2; i <= value; ++i) {
var temp = a;
a = b;
b += temp;
}
return b;
}