Showing posts with label Fibonacci Series Recurrsion. Show all posts
Showing posts with label Fibonacci Series Recurrsion. Show all posts

Wednesday, July 6, 2011

Program to find the Fibonacci Series using Recursion


Fibonacci Series is as follows:-


0,\;1,\;1,\;2,\;3,\;5,\;8,\;13,\;21,\;34,\;55,\;89,\;144,\; \ldots\;


#include<iostream.h>
#include<conio.h>
int fib(int m);
void main()
{
 clrscr();
 int i,n;
 cout<<"Enter the no. of terms"<<endl;
 cin>>n;
 for(i=1;i<=n;i++)
 {
  cout<<fib(i)<<endl;
  getch();
 }
}
int fib(int m)
 {
  if(m==1||m==2)
  return(1);
  else
  return(fib(m-1)+fib(m-2));


 }