Definition of Fibonacci
numbers:
We assume
first two Fibonacci are 0 and 1
A series
of numbers in which each sequent number is sum of its two previous numbers is
known as Fibonacci series and each numbers are called Fibonacci numbers.
So Fibonacci numbers is
Algorithm for Fibonacci
series
Fn = Fn-2 + Fn-1
Example of
Fibonacci series:
0 , 1 ,1 ,
2 , 3 , 5 , 8 , 13 , 21 , 34 , 55 ...
#include<stdio.h>
int
main(){
int k,r;
long int i=0,j=1,f;
//Taking maximum numbers form user
printf("Enter the number range:");
scanf("%d",&r);
printf("FIBONACCI SERIES: ");
printf("%ld %ld",i,j); //printing first two values.
for(k=2;k<r;k++)
{
f=i+j;
i=j;
j=f;
printf(" %ld",j);
}
return 0;
}
Sample
output:
Enter
the number range: 15
FIBONACCI SERIES: 0 1 1 2 3
5 8 13 21 34 55 89 144 233 377
Great Work.. I saw One more easiest way to Write a C Program To Print Fibonacci Series
ReplyDelete