I don't understand why this code is not working

The function below is to calculate the fibonacci sequence using get! but i don’t understand why it is not working.

global fib_cache = Dict{BigInt, BigInt}(0 => 0, 1 => 1)
function fib(n::Integer)
global fib_cache
get!(fib_cache, BigInt(n), fib(n‑1) + fib(n‑2))
end

2 posts were merged into an existing topic: Why is this code not working?

Hi @Nimpa, welcome! Looks like you already started a topic for this — let’s try to keep things consolidated there.

1 Like