Recursive Fibonacci
By definition, the first two Fibonacci numbers are 0 and 1, and each remaining number is the sum of the previous two. Some sources omit the initial 0, instead beginning the sequence with two 1s.
/*
http://www.ProbCOMP.com
By definition, the first two Fibonacci numbers are 0 and 1, and each remaining number is the sum of the previous two. Some sources omit the initial 0, instead beginning the sequence with two 1s.
In this program we have used recursive function to get the fibonacci number at the specified position
*/
#include<stdio.h>
int fibb(int n)
{
if(n<3)
return 1;
else
return fibb(n-1)+fibb(n-2);
}
void main()
{
int n;
printf("Enter the position of the number in fibonacci series: ");
scanf("%d",&n);
printf("\nthe number at the position %d is %d",n,fibb(n));
}
Download Program


