forked from M3-Academy/challenge-algorithms-v2.0
feat(04): finished
This commit is contained in:
parent
18e42e3908
commit
47142e3085
@ -1,4 +1,4 @@
|
|||||||
export function maxValue(values) {
|
export function maxValue(values) {
|
||||||
// implementar logica aqui
|
// implementar logica aqui
|
||||||
|
return Math.max(...values);
|
||||||
}
|
}
|
@ -1,4 +1,14 @@
|
|||||||
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 fibMinus2 = 0
|
||||||
|
let fibMinus1 = 1
|
||||||
|
let fibN = value
|
||||||
|
for(let i = 2; i <= value; i++){
|
||||||
|
fibN = fibMinus1 + fibMinus2
|
||||||
|
fibMinus2 = fibMinus1
|
||||||
|
fibMinus1 = fibN
|
||||||
|
}
|
||||||
|
return fibN
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user