forked from M3-Academy/challenge-algorithms-v2.0
add fibonacci logic
This commit is contained in:
parent
3b2b27070b
commit
c6379b5b4e
@ -1,4 +1,11 @@
|
|||||||
export function fibonacci(value) {
|
export function fibonacci(value) {
|
||||||
// implementar logica aqui
|
if (value == 0) return 0;
|
||||||
|
let firstValue = 0;
|
||||||
}
|
let secondValue = 1;
|
||||||
|
for (let i = 2; i <= value; i++) {
|
||||||
|
let newValue = firstValue;
|
||||||
|
firstValue = secondValue;
|
||||||
|
secondValue += newValue;
|
||||||
|
}
|
||||||
|
return secondValue;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user