Fibonacci Series Using Recursive Function

//fibonacci series using recursive function
#include
#include
long fibo(int n)
{
if ((n==0)(n==1))
return 0 ;
else if
(n==2)
return 1;
else
return (fibo(n-1)+fibo(n-2));
}
void main()
{
int num,i=0;
printf("Enter the no of terms:");
scanf("%d",&num);
while (i++i;
printf("The %dth term of fabonacci series is: %d \n",i,fibo(i));
}
getch();
}

//
Enter the number of terms:4
The 1st term of fibonacci series is:0
The 1st term of fibonacci series is:1
The 1st term of fibonacci series is:1
The 1st term of fibonacci series is:2

No comments: