Merge branch 'feature/04-fibonacci' into development

This commit is contained in:
Andrea Matsunaga 2022-11-01 11:47:57 -03:00
commit 25eb5d604a

View File

@ -1,4 +1,15 @@
export function fibonacci(value) {
// implementar logica aqui
let beforeLastNumber = 0;
let lastNumber = 1;
let nextNumber;
if (value < 2) return value;
for (let i = 2; i <= value; i++) {
nextNumber = lastNumber + beforeLastNumber;
beforeLastNumber = lastNumber;
lastNumber = nextNumber;
}
return lastNumber;
}