(feat)finalizando teste 04 fibonacci

This commit is contained in:
wellington carlos 2022-10-28 20:17:52 -03:00
parent e7260ebf67
commit c31eca56ff

View File

@ -1,4 +1,17 @@
export function fibonacci(value) { export function fibonacci(value) {
// implementar logica aqui if (value < 1) return 0
if (value <= 2) return 1
let fibonnaci1 = 0
let fibonnaci2 = 1
let fibx = value
for (let i = 2; i <= value; i++) {
fibx = fibonnaci2 + fibonnaci1
fibonnaci1 = fibonnaci2
fibonnaci2 = fibx
}
return fibx
} }