Fibonacci Number
Problem statement
Return the nth Fibonacci number using zero-based indexing.
The sequence is defined by F(0) = 0, F(1) = 1, and F(n) = F(n - 1) + F(n - 2) for n >= 2.
Function
fibonacci(n: int) → longExamples
Example 1
n = 0return = 0The first Fibonacci value is defined as F(0) = 0.
Example 2
n = 10return = 55The zero-based sequence begins 0,1,1,2,3,5,8,13,21,34,55.
Constraints
0 <= n <= 91- The result fits in a signed 64-bit integer.