forked from M3-Academy/challenge-algorithms-v2.0
13 lines
232 B
JavaScript
13 lines
232 B
JavaScript
export function fibonacci(value) {
|
|
// implementar logica aqui
|
|
if (value <= 1) {
|
|
return value;
|
|
}
|
|
|
|
let arr = [0, 1];
|
|
|
|
for (let i = 2; i < value + 1; i++) {
|
|
arr[i] = arr[i - 2] + arr[i - 1];
|
|
}
|
|
return arr[value];
|
|
} |