#include<stdio.h>
#include<stdlib.h>
int Fib(int n)
{
if (n == 1 || n == 2)//return当n为1,2的值
{
return 1;
}
return Fib(n - 1) + Fib(n - 2);//递归调用
}
int main()
{
int n = 5;
printf("第%d个斐波那契数为%d\n",n,Fib(n));
system("pause");
return 0;
}
结果