Fibonacci Series


Fibonacci series is a series of n numbers where n can be any natural numbers. The logic behind the fibonacci series is that the evry third number in the series is the sum of its previous two numbers.Lets understand it with the simple example of c/c++.series: 1,1,2,3,5,8,13,21....n

#include
void main(){
int a,b,c,n;
printf("Enter the length of series \n");
scanf("%d",&n);
a=0;
b=1;
printf("Series :%d %d ",a,b);
for(int i=0;i<n;i++){
c=a+b;
a=b;
b=c;
printf("%d",c); } }