← 返回 snowflake 的题目列表Calculate Fibonacci Number
类型:online_judge
Implement a function to calculate the Fibonacci number at a given position. The Fibonacci sequence is defined as:
F(0) = 0, F(1) = 1
For n >= 2, F(n) = F(n-1) + F(n-2)
The function input is an integer n, and the return value is the nth Fibonacci number.
Example:
Input: 5
Output: 5
Constraints:
0 <= n <= 30
Example
Input
0