Generation of the Fibonacci Sequence

 

The Fibonacci sequence is a series of numbers where each number (called a Fibonacci number) is the sum of the two preceding ones, starting from 0 and 1. The sequence begins as follows:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …

 

Explanation

 

Objective :

The objective is to generate the first 𝑛 numbers of the Fibonacci sequence.

Steps
  1. Input: Get the number of terms 𝑛 to generate.
  2. Initialize: Start with the first two terms of the sequence (0 and 1).
  3. Iterate: Use a loop to calculate each subsequent term by summing the two preceding terms.
  4. Output: Print each term of the sequence.

 

Algorithm in Pseudo-Code

 

C Implementation

 

Output