Toggle navigation
万里ACM
F.A.Qs
Web Board
ProblemSet
Source/Category
Status
Ranklist
Contest
[
ProblemSet
Status
Ranklist
OI Ranklist
Statistics
]
Login
Problem B: 使用递归函数计算Fibonacci数列第n项
Problem B: 使用递归函数计算Fibonacci数列第n项
Time Limit:
1 Sec
Memory Limit:
128 MB
Submit:
72
Solved:
68
[
Submit
] [
Status
] [
Web Board
] [Creator:
]
Description
Fibonacci数列的递归定义形式为
根据公式编写递归函数 int f(int n);计算Fibonacci数列的第n项
Input
正整数n(n≤40)
Output
Fibonacci数列的第n项
Sample Input
Copy
5 10
Sample Output
Copy
5 55
HINT
用于测试函数的源程序:
#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
printf("%d\n", f(n) );
}