Home / EG Comp Lab / C Language / Fibonacci Numbers: C Program

Fibonacci Numbers: C Program

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


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.

C program;Fibonacci numbers
An approximation of the golden spiral created by drawing circular arcs connecting the opposite corners of squares in the Fibonacci tiling; this one uses squares of sizes 1, 1, 2, 3, 5, 8, 13, 21, and 34.
[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:”);

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

for ( c = 0 ; c < n ; c++ )
if ( c <= 1 )
next = c;
next = first + second;
first = second;
second = next;


[/message_box] [message_box title=”Output” color=”red”] Enter the number of terms:6
First 8 terms of Fibonacci series are :-


About Utpal

I am third year student of computer engineering in L.D COLLEGE OF ENGINEERING,Ahmedabad.

Check Also

Independent Directed Acyclic Graphs for Resilient Multipath Routing

ABSTRACT: In order to achieve resilient multipath routing, we introduce the concept of independent directed …

Leave a Reply

Be the First to Comment!

Notify of