forked from M3-Academy/challenge-algorithms-v2.0
feat(fibonacci): Adiciona a logica do algoritmo que resolve a função de Fibonacci
This commit is contained in:
parent
8aa3869a4f
commit
6c3fdd70b2
@ -1,4 +1,14 @@
|
||||
export function fibonacci(value) {
|
||||
// implementar logica aqui
|
||||
|
||||
let fibM = value;
|
||||
let fibMinus1 = 0;
|
||||
let fibMinus2 = 1;
|
||||
|
||||
|
||||
for (let i = 0; i < value; i++) {
|
||||
fibM = fibMinus1 + fibMinus2;
|
||||
fibMinus1 = fibMinus2;
|
||||
fibMinus2 = fibM;
|
||||
}
|
||||
return fibMinus1
|
||||
}
|
Loading…
Reference in New Issue
Block a user