Flowchart Updated 12/2/2026

Fibonacci Series Flowchart

Fibonacci series flowchart: keep the last two terms in a and b, print a, then slide the pair forward with c = a + b. With a trace of the first 7 terms (0 1 1 2 3 5 8), pseudocode, and tested Python, C and Java code.

fibonacci seriesflowchartloopsalgorithmsprogramming
9 nodes 9 connections

Study guide

Fibonacci Series FlowchartStartRead nSet a = 0, b = 1, i =1i <= n?Print aSet c = a + bSet a = b, then b = cSet i = i + 1EndYesNo
Fibonacci Series Flowchart. Source: https://www.chartcraft.dev/examples/fibonacci-series-flowchart

What the Fibonacci series flowchart shows

In the Fibonacci series each term is the sum of the two before it: 0, 1, 1, 2, 3, 5, 8, 13, and so on. A Fibonacci series flowchart only ever remembers two numbers, a and b; on each pass it prints a, works out the next term c = a + b, and slides the window one step along.

Think of a and b as two footprints walking up the series: the back foot always steps to where the front foot was.

Fibonacci series flowchart, step by step

  1. terminator StartOne Start terminator opens the flowchart.
  2. input/output Read nReads how many terms to print.
  3. process Set a = 0, b = 1, i = 1The first two terms are 0 and 1. i counts how many terms have been printed, starting at term 1.
  4. decision i <= n?Yes prints another term. No means n terms are printed and the program ends.
  5. input/output Print aPrints the current term a.
  6. process Set c = a + bWorks out the term after b. A third variable is needed because a is about to be overwritten.
  7. process Set a = b, then b = cSlides the pair forward. The order matters: copy b into a first, then c into b.
  8. process Set i = i + 1Counts the printed term and loops back to the test.
  9. terminator EndReached from the No exit.

Dry run: trace table for n = 7

Each row is one test of i <= n?. The last three columns show the values after the step is done.

ii <= n?Printed ac = a + bnew anew b
1Yes0111
2Yes1212
3Yes1323
4Yes2535
5Yes3858
6Yes513813
7Yes8211321
8Nonothingnot runnot runnot run

Output: 0 1 1 2 3 5 8. Notice the loop calculates two terms (13 and 21) that it never prints. That is fine: it is the price of keeping the loop simple.

Fibonacci series pseudocode

Pseudocode
READ n
a = 0
b = 1
FOR i = 1 TO n
    PRINT a
    c = a + b
    a = b
    b = c
NEXT i

Fibonacci series in Python, C and Java

Python
n = int(input())

a = 0
b = 1
i = 1
while i <= n:
    print(a, end=" ")
    c = a + b
    a = b
    b = c
    i = i + 1
print()
C
#include <stdio.h>

int main(void) {
    int n;
    scanf("%d", &n);

    long long a = 0, b = 1, c;
    for (int i = 1; i <= n; i++) {
        printf("%lld ", a);
        c = a + b;
        a = b;
        b = c;
    }
    printf("\n");
    return 0;
}
Java
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        long a = 0, b = 1, c;
        for (int i = 1; i <= n; i++) {
            System.out.print(a + " ");
            c = a + b;
            a = b;
            b = c;
        }
        System.out.println();
    }
}
Input typed at the keyboard
7
Output of all three programs
0 1 1 2 3 5 8

All three programs were compiled and run with the input 7 before publishing. Each prints the terms on one line with a trailing space after the last one.

Mistakes examiners see most

  • Shifting in the wrong order. Writing b = c before a = b makes a and b equal, and the series turns into 0, 1, 2, 4, 8 (doubling). Copy b into a first.
  • Forgetting the third variable. a = b then b = a + b uses the new a, which is wrong. Either use c, or in Python write a, b = b, a + b, which reads both old values first.
  • Printing b instead of a. Then the series starts 1, 1, 2 and the 0 is lost. Check your exam board's convention: most start at 0.
  • Off-by-one in the count. Starting i at 0 with the test i <= n prints n + 1 terms. Start at 1 with <=, or at 0 with <.

Practice questions with worked answers

Q1 What are the values of a and b after the third pass of the loop?

a = 2 and b = 3.

Read the third row of the trace: the new a is 2 and the new b is 3. The next term printed will be 2.

Q2 Change the flowchart so it prints only the terms that are less than 50, however many there are.

Replace the counter with a value test: the diamond becomes a < 50?, and Read n, i = 1 and Set i = i + 1 are removed.

Pseudocode
a = 0
b = 1
WHILE a < 50
    PRINT a
    c = a + b
    a = b
    b = c
ENDWHILE

It prints 0 1 1 2 3 5 8 13 21 34.

Q3 Write a Python version that uses tuple assignment instead of c, and check it prints the same series.
Python
a, b = 0, 1
for i in range(7):
    print(a, end=" ")
    a, b = b, a + b
print()

The right-hand side b, a + b is worked out completely before anything is assigned, so the old a is still used. That removes the need for a third variable.

Flowchart symbols used and why

SymbolShape to draw on paperWhere it appears hereWhy
TerminatorRounded boxStart and EndOne entry, one exit.
Input/outputParallelogramRead n and Print aData in and each term out.
ProcessRectangleThe setup box, Set c = a + b, the shift and the updateEach one calculates or moves values.
DecisionDiamondi <= n?Decides whether another term is needed.
LoopA decision whose flow line returns to an earlier stepThe arrow from Set i = i + 1 back to i <= n?Repeats the print and shift once per term.

In the interactive diagram every step is a labelled card: the small word above each step names its kind (process, decision or data). When you draw this flowchart by hand, use the standard shapes in the table. The full list is on the flowchart symbols page.

Make your own version

Each link opens the editor with a prompt already filled in. Change the wording, then generate your own flowchart.

How can I use this flowchart?

Download the Fibonacci Series Flowchart as a PNG or SVG, or open it in the studio to edit your own copy. To draw a similar flowchart from a description, use the flowchart generator; for notation and a step-by-step walkthrough, read how to make a flowchart; and browse more flowchart examples for related layouts.

Try the studio with your own description.

Type any system, process, or schema in plain English. ChartCraft will draw it in seconds.