Site icon

Flowgorithm Infinite Recursion Example


In this tutorial, we will understand Infinite Recursion, the common mistake that programmers make while designing recursive functions in Flowgorithm flowcharts.

A recursive function is a function that invokes itself. Let’s understand it with a simple example.

A simple example of infinite recursion occurs when the Main flowchart invokes itself. In this example, the flowchart will fall in infinite recursion and the control never reaches the End symbol.


Stack Overflow

This error indicates that the Maximum Stack Size has been exceeded by the program.  If the flowchart program exceeds this size in the case of an infinite recursive call, the following runtime error would be displayed: Stack Overflow

The Flowgorithm tool uses a Stack to store function activation records.  An activation record is a chunk of memory that stores the function parameters, local variables, and the function return value.


Let’s take another example from the earlier post. The recursive function is RSum.

The recursive function example is from the post: Recursion In Flowgorithm Flowchart



Call Stack

To view the Call Stack, launch the Variable Watch Window and click on the ‘Show the Stack’ button. We can notice that the recursion doesn’t have a base case.

A base case is a halting case that stops the recursion. In the base case, the function returns and doesn’t call itself. In this case, the recursion doesn’t stop and results in an infinite recursion.



To fix the flowchart we need to debug and stop the recursion using the base case. In this case, when N == 1 we can make the function return sum = 1 instead of calling recursively itself which is a defect.

Flowgorithm Tutorials

Flowgorithm flowchart tutorials on this website:

Flowgorithm Website

For more information on the Flowgorithm tool, please visit the official website at:

Exit mobile version