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^5n = 0Output0WhyF(0) is defined as 0.n = 7Output13WhyComputing forward: 0, 1, 1, 2, 3, 5, 8, 13 → the 7th value is 13.n = 10Output55WhyThe sequence up to 10 is 0,1,1,2,3,5,8,13,21,34,55.0 <= n <= 10^5n is an integerReturn the exact value of F(n) (no modulo)def fib(n: int) -> int: