2022-10-27 15:07:13 +00:00
|
|
|
export function fibonacci(value) {
|
|
|
|
// implementar logica aqui
|
2022-10-31 17:39:52 +00:00
|
|
|
if (value < 1) {
|
|
|
|
return 0;
|
2022-10-30 12:32:36 +00:00
|
|
|
} else if (value <= 2) {
|
2022-10-31 17:39:52 +00:00
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
let previous = 0;
|
|
|
|
let next = 1;
|
|
|
|
let total;
|
|
|
|
for (let i = 2; i <= value; i++) {
|
|
|
|
total = next + previous;
|
|
|
|
previous = next;
|
|
|
|
next = total;
|
|
|
|
}
|
|
|
|
return total;
|
|
|
|
}
|
2022-10-30 12:27:58 +00:00
|
|
|
}
|