2022-10-27 15:07:13 +00:00
|
|
|
export function fibonacci(value) {
|
2022-10-28 22:21:13 +00:00
|
|
|
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;
|
2022-10-27 15:07:13 +00:00
|
|
|
|
|
|
|
}
|