#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,x,fibo(int);
clrscr();
printf("\n\n Enter the number of elements:");
scanf("%d",&n);
printf("\n\n The fibonacci series is:");
for(i=0; i<n+1; i++)
{
printf("\n%d",fibo(i));
}
getch();
}
int fibo(int a)
{
if(a==0)
{
return(0);
}
else if(a==1)
{
return(1);
}
else
{
return(fibo(a-1)+fibo(a-2));
}
}
No comments:
Post a Comment
Convey your thoughts to authors.