Fibonacci series :
A series in which each element are the sum of previous two elements is known as Fibonacci series.
Example-
0 1 1 2 3 5 8 13 ................
program:
#include < iostream>
using namespace std;
class r4r
{
public:
int fibo(int n,int a,int b)
{
if(n==2)
return 0;
cout<< a+b<<" ";
fibo(n-1,b,a+b);
}
};
int main()
{
r4r obj;
int n;
cout<<"Enter number of term"<< endl;
cin>>n;
cout<<"0 1 ";
obj.fibo(n,0,1);
return 0;
}
Enter number of terms
7
0 1 1 2 3 5 8 13