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