求解f(n)数列的第n项的值。

求解的表达式f(n)
数列1 1 2 3 5 8 13 21..........的第n项的值

 n=(1,2,3,4,..........)


#include<iostream>
using namespace std;
int Recursion(int n)
{
	int t;
    if(n==1||n==2)
    t=1;
    else
    t=Recursion(n-1)+Recursion(n-2);
	return  t; 
  }
  int main()
  {
  	int n;
  	cin>>n;
  	cout<<endl;
  	cout<<Recursion(n)<<endl;
	}  

猜你喜欢

转载自blog.csdn.net/qq_42387291/article/details/82819066