TOPIC

WA 100% JavaScript

jamerico1 asked 2 years ago

const n = parseInt(lines.shift().split(" "))
let calls = 0

function fib(n) {
    calls++
    if(n < 2) {
        return n
    } else {
        return fib(n - 1) + fib(n - 2)
    }
}

const result = fib(n)

console.log(`fib(${result}) = ${calls} calls = ${result}`)

Qual o problema com o meu código?

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.