forked from M3-Academy/challenge-algorithms-v2.0
feat: Algoritmo 04-fibonacci - finalizado
This commit is contained in:
parent
753a4a9c77
commit
a55909d38f
@ -1,4 +1,20 @@
|
||||
export function fibonacci(value) {
|
||||
// implementar logica aqui
|
||||
|
||||
let fibMenor1 = 0;
|
||||
let fibMenor2 = 1;
|
||||
let fibN = 0;
|
||||
|
||||
if(value < 2){
|
||||
return value;
|
||||
}
|
||||
|
||||
for (let i = 1; i <= value; i++){
|
||||
fibN = fibMenor1 + fibMenor2;
|
||||
fibMenor2 = fibMenor1;
|
||||
fibMenor1 = fibN;
|
||||
}
|
||||
|
||||
return fibN;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user