/* pgm to compute factorial & generate fibonacci of a number*/
#include<stdio.h>
long int fact(int);
int fibo(int);
void main()
{
int n,i,ch;
long int x;
clrscr();
printf("\n\t\tPROGRAM TO COMPUTE FACTORIAL & GENERATE FIBONACCI SERIES\n\n");
do
{
printf("\n\n\tEnter the Number : ");
scanf("%d",&n);
if(n<0)
printf("\n\nInvalid Number.Try Again");
}while(n<0);
printf("\n\t %d ! = %ld\n",n,fact(n));
printf("\n\n\t\tFIBONACCI SERIES\n\n\t");
if(n==0) printf("\n\n\tZERO SERIES CAN'T BE GENERATED\n\n");
else
for(i=1;i<=n;i++)
printf("%d\t",fibo(i));
getch();
}
long int fact(int n)
{
if(n==0 || n==1)
return 1;
else
return(n*fact(n-1));
}
int fibo(int n)
{
if(n==1) return 0;
else if(n==2) return 1;
return(fibo(n-1)+fibo(n-2));
}