#include<stdio.h>
#include<conio.h>
long fibonacci(int);
void main()
{
int i,n;
clrscr();
printf(" Enter the number of terms required in the series ");
scanf("%d",&n);
printf("\n Series is :\n");
for(i=1;i<=n;i++)
{
printf(" %ld",fibonacci(i));
}
getch();
}
long fibonacci(int n)
{
if(n==1 || n==2)
return 1;
else
return (fibonacci(n-1)+fibonacci(n-2));
}
Appreciation for nice Updates, I found something new and folks can get useful info about BEST ONLINE TRAINING
ReplyDelete#include
ReplyDelete#include
int fib(int n);
void main()
{
int n,i;
printf(" enter the no. of terms");
scanf("%d", &n);
for(i=0;i<n;i++)
{
printf("%d\n",fib(i));
}
}
int fib(int n)
{
if(n==1)
return(1);
else
return(fib(n-1)+fib(n-2));
}