Loading...
You are given an integer n. The Fibonacci sequence is defined by F(0) = 0, F(1) = 1, and F(i) = F(i - 1) + F(i - 2) for every i >= 2.
n
F(0) = 0
F(1) = 1
F(i) = F(i - 1) + F(i - 2)
i >= 2
Return F(n). Mod the result by 10 ** 9 + 7.
F(n)
10 ** 9 + 7
Input: n = 0 Output: 0 Explanation: By definition, `F(0) = 0`.
Input: n = 10 Output: 55 Explanation: The sequence starts 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, so `F(10) = 55`.
Input: n = 50 Output: 586268941 Explanation: `F(50) = 12586269025`, and the remainder of `12586269025` modulo `10 ** 9 + 7` is `586268941`.