2022-10-27 15:07:13 +00:00
|
|
|
export function fibonacci(value) {
|
|
|
|
// implementar logica aqui
|
2022-10-31 17:19:47 +00:00
|
|
|
if(value == 0){
|
|
|
|
return value;
|
2022-10-28 18:02:21 +00:00
|
|
|
}
|
2022-10-31 17:19:47 +00:00
|
|
|
let firstValue = 0, secondValue = 1, thirdValue =1;
|
|
|
|
for(let i = 2; i <= value; i++){
|
|
|
|
thirdValue = firstValue + secondValue;
|
|
|
|
firstValue = secondValue;
|
|
|
|
secondValue = thirdValue;
|
|
|
|
}
|
|
|
|
return thirdValue;
|
|
|
|
// if(value < 2){
|
|
|
|
// value = value;
|
|
|
|
// }else{
|
|
|
|
// value = fibonacci(value - 1) + fibonacci(value - 2);
|
|
|
|
// }
|
|
|
|
// return value;
|
2022-10-27 15:07:13 +00:00
|
|
|
}
|