#include "stdio.h"
#include "conio.h"
long int fib(int); /* Function Prototype */
void main()
{
int n,i;
long int result;
printf("Enter Nth Term : ");
scanf("%d",&n);
i = 0;
while(i < n)
{
result = fib(i++); /* function Call */
printf("%ld\t",result);
}
getch();
}
/* End of Main */
long int fib(int m) /* Function Definition */
{
if (m == 0) /* Control Statements for Recurrsion */
return 0;
else if(m == 1 || m == 2)
return 1;
else
return fib(m-1) + fib(m-2); /* Recursive Statement */
}
/* End of Program */
Saturday, December 5, 2009
FIBONACCI SERIES USING RECURRSION
Labels: Recurrsion
Posted by Unknown at 11:27 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment