You’re working on a fintech platform that processes millions of card authorizations per day. A legacy risk-throttling rule uses a Fibonacci-based backoff schedule to decide how long to delay repeated verification attempts for suspicious sessions. Because this function is called frequently in latency-sensitive paths, you need an implementation that is correct and efficient.
Implement a function fib(n) that returns the nth Fibonacci number.
We define the Fibonacci sequence as:
F(0) = 0F(1) = 1F(n) = F(n-1) + F(n-2) for n >= 2n (0-indexed)F(n) as an integer.Example 1
n = 00Example 2
n = 713F(2)=1, F(3)=2, F(4)=3, F(5)=5, F(6)=8, F(7)=13.0 <= n <= 10^5