#include <stdio.h>
int fibo(int n)
{
if(n==0)
{
return 0;///base case
}
else if(n==1)
{
return 1; ///base case
}
else
{
return fibo(n-1)+fibo(n-2); ///calling the function again and again
}
}
int main()
{
int n,i;
printf("please Enter a Value: ");
scanf("%d",&n);
printf("
Series: ");
for(i=0;i<n;i++)
{
printf("%d ",fibo(i));
}
printf("
");
return 0;
}
Output
please Enter a Value: 10
Series: 0 1 1 2 3 5 8 13 21 34
Add your comment