feat(challenge-4): completed challenge

This commit is contained in:
Henrique Santos Santana 2022-10-27 20:51:29 -03:00
parent 83dac1b3eb
commit dbbbb6c4c6

View File

@ -1,4 +1,16 @@
export function fibonacci(value) { export function fibonacci(value) {
// implementar logica aqui // implementar logica aqui
if (!value) return 0;
let n1 = 0,
n2 = 1,
nextTerm;
for (let i = 1; i <= value; i++) {
nextTerm = n1 + n2;
n1 = n2;
n2 = nextTerm;
}
return n1;
} }