C program to Display Fibonacci series
- The Fibonacci sequence is the series of numbers, in which
each number is the sum of the two numbers that precede it.
- So the sequence goes : 0,1,1,2,3,5,8,13,21,34 and so on.
- The next number is found by adding up the two numbers before
it :
- 2 is found by adding
1 and 1 which is [1+1=2]
- 34 is found by adding
13 and 21 which is [13+21=34]
About the discoverer of Fibonacci series
- Leonardo Pisano Bogollo discovered the Fibonacci series.
- Fibonacci was his nickname, which means the son of Bonacci.
C program to Display Fibonacci series
- #include<stdio.h>
- int main()
- {
- int num1 =
0;
- int num2 =
1;
- int num3 =
0;
- int i = 0;
- int number
= 0;
- printf("Enter
the number of fibonacci to be printed : ");
- scanf("%d",&number);
- printf("\n
%d\n %d\n",num1,num2);
- for(i = 2;
i < number; ++i)
- {
- num3 =
num1+num2;
- printf("
%d \n",num3);
- num1 =
num2;
- num2 =
num3;
- }
- return 0;
- }
0 Comments
If you have any doubts, Please let me know