forked from M3-Academy/challenge-algorithms-v2.0
13 lines
215 B
JavaScript
13 lines
215 B
JavaScript
export function fibonacci(value) {
|
|
let previous = 0;
|
|
let sum = 0;
|
|
let next = 1;
|
|
|
|
for (let i = 0; i < value; i++) {
|
|
sum = previous + next;
|
|
previous = next;
|
|
next = sum;
|
|
}
|
|
return previous;
|
|
|
|
} |