forked from M3-Academy/challenge-algorithms-v2.0
16 lines
206 B
JavaScript
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;
|
|
|
|
} |