feat: criar algoritmo que realize a sequencia de fibonacci

This commit is contained in:
HUMBERTO ANTONIO CORREIA FERRO 2022-10-29 07:37:20 -03:00
parent 1b9c0dbafe
commit 31c440491f

View File

@ -1,4 +1,14 @@
export function fibonacci(value) {
// implementar logica aqui
if (value < 1) return 0
if (value <= 2) return 1
let fib1 = 0
let fib2 = 1
let fibN = value
for (let i = 2; i <=value; i++){
fibN = fib2 + fib1
fib1 = fib2
fib2 = fibN
}
return fibN
}