Home >>c programs >Fibonacci Series in C
Fibonacci series in C defined the sequences of a number in recurrence relation.
It generates subsequent number by adding second and third term preceding number and not using the first term. It can be done as requested by the user until the number of terms.
In case of Fibonacci series like 0, 1, 1, 2, 3, 5, 8, 13, 21 etc., except for the first two number of the series (0, 1), every other third term is made by adding the Previous two numbers.
For example:
0, 1, 1, 2, 3, 5, 8, 13, 21 etc.
Let's understand this example in brief:-
1+1 = 2, 1+2= 3, 3+2 = 5, 5+3 = 8
Let's take an example of Fibonnacci series:
#include<stdio.h> int main() { int x=0,y=1,z,i,number; printf("Enter Your number of how many times you want to print series:"); scanf("%d",&number); printf("\n%d %d",x,y);//First we print 0 and 1 for(i=2;i<number;++i)//Now we need to start loop from 2 because 0 and 1 already we have print. { z=x+y; printf(" %d",z); x=y; y=z; } return 0; }