feature/algoritimos #1

Merged
RamonDiasFerreira merged 11 commits from feature/algoritimos into master 2022-11-02 19:48:31 +00:00
Showing only changes of commit aaed0ee98d - Show all commits

View File

@ -1,4 +1,25 @@
export function fibonacci(value) { export function fibonacci(value) {
// implementar logica aqui // implementar logica aqui
if(value < 1) return 0
if(value <=2) return 1
let fibMin2 = 0
let fibMin1 = 1
let fibValue = value
for(let i = 2; i <= value; i++) {
fibValue = fibMin1 + fibMin2
fibMin2 = fibMin1
fibMin1 = fibValue
}
return fibValue
// Forma inicial pensada, mas demorava muito tempo para passar nos testes.
// if(value === 0) {
// return 0
// }
// else if (value <= 2) {
// return 1
// }
// return fibonacci(value - 1) + fibonacci(value - 2);
} }