Showing posts with label Fibonacci. Show all posts
Showing posts with label Fibonacci. Show all posts

Saturday, August 9, 2014

Program to implement Fibonacci series

Program to implement Fibonacci series. Comment if you need any help.

#include<stdio.h>
int fibo(int x);
main()
{
int n,i,ar[50];
printf("\n  enter the number of terms:");
scanf("%d",&n);
ar[0]=0;
for(i=1;i<n;i++)
{
ar[i]=fibo(i);
}
printf("\n");
for(i=0;i<n;i++)
printf("%d ",ar[i]);
printf("\n");
}
int fibo(int c)
{
int fib=0;
if((c==1)||(c==2))
return 1;
else
{
fib=fibo(c-1)+fibo(c-2);
return fib;
}
}