# Fibonacci Numbers: C Program

0
1032

Fibonacci series in C programming: C program for Fibonacci series without and with recursion. Using the code below you can print as many numbers of terms of series as desired. Numbers of Fibonacci sequence are known as Fibonacci numbers. First few numbers of series are 0, 1, 1, 2, 3, 5, 8 etc, Except first two terms in sequence every other term is the sum of two previous terms, For example 8 = 3 + 5 (addition of 3, 5). This sequence has many applications in mathematics and Computer Science.

In mathematics, the Fibonacci numbers or Fibonacci sequence are the numbers in the following integer sequence:[1][2]

$1,\;1,\;2,\;3,\;5,\;8,\;13,\;21,\;34,\;55,\;89,\;144,\; \ldots\;$

or (often, in modern usage):

$0,\;1,\;1,\;2,\;3,\;5,\;8,\;13,\;21,\;34,\;55,\;89,\;144,\; \ldots\;$ (sequence A000045 in OEIS).

By definition, the first two numbers in the Fibonacci sequence are 1 and 1, or 0 and 1, depending on the chosen starting point of the sequence, and each subsequent number is the sum of the previous two.

In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation

$F_n = F_{n-1} + F_{n-2},\!\,$

with seed values[1][2]

$F_1 = 1,\; F_2 = 1$

or[3]

$F_0 = 0,\; F_1 = 1.$

The Fibonacci sequence is named after Fibonacci. His 1202 book Liber Abaci introduced the sequence to Western European mathematics,[4]although the sequence had been described earlier in Indian mathematics.[5][6][7] By modern convention, the sequence begins either with F0Â =Â 0 or with F1Â =Â 1. The Liber Abaci began the sequence with F1Â =Â 1, without an initial 0.

[message_box title=”Program ” color=”red”]

/* Write a program to calculate Fibonacci series */

/* Written by Utpal Chaudhary */

/*Student of L.D COLEGE OF ENGINEERING,Ahmedabad-15,Gujarat */

#include <stdio.h>
#include <conio.h>

void main()
{
int n, first = 0, second = 1, next, c;

printf(“Enter the number of terms:”);
scanf(“%d”,&n);

printf(“First %d terms of Fibonacci series are :-\n”,n);

for ( c = 0 ; c < n ; c++ )
{
if ( c <= 1 )
next = c;
else
{
next = first + second;
first = second;
second = next;
}
printf(“%d\n”,next);
}

getch();
}

[/message_box]

[message_box title=”Output” color=”red”]
Enter the number of terms:6
First 8 terms of Fibonacci series are :-
0
1
1
2
3
5
8
13

[/message_box]

SHARE
Previous article74LS04 IC
Next articlecapacitor
I am third year student of computer engineering in L.D COLLEGE OF ENGINEERING,Ahmedabad.

### Leave a Reply

Please Login to comment
Subscribe
Notify of