forked from M3-Academy/challenge-algorithms-v2.0
feat: criação da resposat do 04-fibonacci
This commit is contained in:
parent
aab21161ae
commit
8947b76351
@ -1,4 +1,17 @@
|
||||
export function fibonacci(value) {
|
||||
// implementar logica aqui
|
||||
let number1 = 0;
|
||||
let number2 = 1;
|
||||
let result;
|
||||
|
||||
if (value === 0 || value === 1 ) {
|
||||
return value;
|
||||
} else {
|
||||
for (let i = 1 ; i < value ; i++) {
|
||||
result = number2 + number1;
|
||||
number1 = number2;
|
||||
number2 = result;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
Loading…
Reference in New Issue
Block a user