#include <stdio.h>
#include <conio.h>
int fib(int ,int , int , int);
main()
{
int n,f,x=0,y=1,i=3;
printf("\n enter length of series : ");
scanf("%d",&n);
printf("\n%d\t%d",x,y);
fib(x,y,n,i);
getch();
}
fib(int x, int y, int n, int i)
{
int z;
if (i<=n)
{
z = x+y; printf("\t%d",z);
x = y;
y =z;
i++;
fib(x,y,n,i);
}
}
No comments:
Post a Comment