diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..101103f 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,4 @@ export function maxValue(values) { // implementar logica aqui - + return Math.max(...values); } \ No newline at end of file diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..2823038 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,14 @@ export function fibonacci(value) { // implementar logica aqui - + if (value < 1) return 0 + if (value <= 2) return 1 + let fibMinus2 = 0 + let fibMinus1 = 1 + let fibN = value + for(let i = 2; i <= value; i++){ + fibN = fibMinus1 + fibMinus2 + fibMinus2 = fibMinus1 + fibMinus1 = fibN + } + return fibN } \ No newline at end of file