# Fibonacci series Program in C | C program to generate Fibonacci Series up to given Number

### Description :

A series of whole numbers in which each number is the sum of the two preceding numbers. Beginning with 0 and 1, the sequence of Fibonacci numbers would be 0,1,1, 2, 3, 5, 8, 13, 21, 34, etc.

formula to calculate Fibonacci Series n = n(-1) + n(-2),

where the n(-1) means “the last number before n in the series” and n(-2) refers to “the second last one before n in the series.”

### Program :

1. #include<stdio.h>
2. int main()
3. {
4.         int i,j,k,num;
5.         printf(“Enter any positive Number : “);
6.         scanf(“%d”,&num);
7.         /* because No Fibonacci series for Negative
8.          * Numbers,. please enter more than 0. ex: 1,50,100.
9.          */
10.         if(num > 0)
11.         {
12.                 printf(“Fibonacci series is :”);
13.                 i=0;
14.                 j=1;
15.                 printf(” %d %d “,i,j);
16.                 k=i+j;
17.                 while(<= num)
18.                 {
19.                         printf(“%d “,k);
20.                         i=j;
21.                         j=k;
22.                         k=i+j;
23.                 }
24.         }
25.         else
26.         {
27.                 printf(“No fibonacci series for Negative Numbersn);
28.         }
29.         printf(n);
30. }

### Related Posts : Venkat

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.