TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Flowgorithm

Recursion in Flowgorithm Flowchart

Flowgorithm

Overview

In this tutorial, we will understand Recursion using Flowgorithm flowchart. In the earlier example using Function, we have noticed that the Main flowchart calls the function. However, a recursive function is a function that calls itself. A function that calls itself is a recursive function.

Mathematical notation for the sum is

\LARGE Sum = 1 + 2 + 3 + ... + (n-2) + (n-1) + n

 

\LARGE Sum = \sum_{i=1}^{n} i

Alternatively, we can define the sum series as:

\LARGE Sum = n + (n-1) + (n-2) + ... + 3 + 2 + 1

Recursive calls

Let’s design a recursive function to compute the sum of N positive numbers called RSum.  Sum of n numbers in recursive format:

Base case: When n= 1 the sum is 1. This is the halting case. We should tell the function to stop the recursive calls.

Recursive case:

RSum = n + RSum(n-1)

This in turn changes to in the next recursion:

RSum = n + (n-1) + RSum(n-2)

and so on until we reach the base case.

Example Flowchart

RSum is the recursive function. The Main function prompts the user for the number N. The Main function invokes the recursive function with the parameter N.

Recursive Flowchart Flowgorithm

 

The recursive function RSum calls itself to compute the sum of N natural numbers.

Recursive Function Call

Sample Output

Execute the Main flowchart and verify the output.

If the flowchart is N the flowchart output of the recursive function should be:

N*(N+1)/2

 

Recursive Function Output

—

Flowgorithm Tutorials Link:

https://www.testingdocs.com/flowgorithm-flowchart-tutorial/

Flowgorithm Website:

http://flowgorithm.org/

Related Posts

Initial Blank Flowchart Flowgorithm3

Flowgorithm /

Draw a Square using Turtle Graphics

File Not Found Flowgorithm Flowchart

Flowgorithm /

Flowgorithm File Errors

File Open Write Mode Statement

Flowgorithm /

Write to Text File using Flowgorithm

File Open Read Mode Flowgorithm

Flowgorithm /

Read Text File using Flowgorithm

New Turtle Graphics Symbols

Flowgorithm /

Flowgorithm Turtle Graphics Flowchart

‹ Arrays in Flowgorithm Flowchart› Populate Array with User Input in Flowchart

Recent Posts

  • Flowchart Control structures
  • Draw a Square using Turtle Graphics
  • Flowgorithm File Errors
  • Write to Text File using Flowgorithm
  • Read Text File using Flowgorithm
  • Flowgorithm Turtle Graphics Flowchart
  • Update Flowgorithm to Latest Version
  • Flowgorithm File Symbols
  • Flowgorithm Turtle Graphics
  • Flowgorithm 3 New Features

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version