1、question:find The nth number offibonacci sequence
In mathematics, the Fibonaccinumbers are the numbers in the following integer sequence, calledthe Fibonacci sequence, and characterized by the fact that everynumber after the first two is the sum of the two preceding ones:
1 1 2 3 5 8 13 21 34 55 89 144.....
2、code:
#include<iostream>
#include<cstdio>
using namespace std;
int fib(int a)
{
if(a==0) return 0;
if(a==1) return 1;
else
{
return fib(a-1)+fib(a-2);
}
}
int n;
int main()
{
cin>>n;
cout<<fib(n);
return 0;
}
3、running