forked from M3-Academy/challenge-algorithms-v2.0
feat: resolucao funcao fibonacci
This commit is contained in:
parent
67faa57ff2
commit
81678ac150
@ -1,4 +1,11 @@
|
|||||||
export function fibonacci(value) {
|
export function fibonacci(value) {
|
||||||
// implementar logica aqui
|
// implementar logica aqui
|
||||||
|
|
||||||
|
const sequence = [0, 1];
|
||||||
|
for (let i = 2; i <= value; i++) {
|
||||||
|
sequence[i] = sequence[i - 2] + sequence[i - 1];
|
||||||
|
}
|
||||||
|
return sequence[value];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fibonacci(0) // 0
|
Loading…
Reference in New Issue
Block a user