Problem1221--递归求Fabonacci数列

1221: 递归求Fabonacci数列

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 0  Solved: 1
[Submit] [Status] [Web Board] [Creator:]

Description

本题要求实现求Fabonacci数列项的函数。Fabonacci数列的定义如下: f(n)=f(n−2)+f(n−1) (n≥2),其中f(0)=0,f(1)=1。 函数接口定义: int f( int n ); 函数f应返回第n个Fabonacci数。题目保证输入输出在长整型范围内。建议用递归实现。 裁判测试程序样例: #include int f( int n ); int main() { int n; scanf(

Input

正整数n

Output

正整数n

Sample Input Copy

6

Sample Output Copy

8

Source/Category