#include<stdio.h>
int fib(int a)
{
if(a==0)
return 0;
else if(a==1)
return 1;
else
return(fib(a-1)+fib(a-2));
}
void main()
{
int n,i;
printf("\nEnter the number of terms");
scanf("%d",&n);
for(i=0;i<n;i++)
printf("\n%d",fib(i));
}
int fib(int a)
{
if(a==0)
return 0;
else if(a==1)
return 1;
else
return(fib(a-1)+fib(a-2));
}
void main()
{
int n,i;
printf("\nEnter the number of terms");
scanf("%d",&n);
for(i=0;i<n;i++)
printf("\n%d",fib(i));
}
No comments:
Post a Comment
Thank you for using this blog.