Example Code

Recursive Fibonacci Calculator Using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview

This example shows the new drag and drop recursion interface to generate the Fibonacci sequence.

 

Description

A recursive function calls itself as a part of its own definition. Recursion is an advanced programming concept that can be used to reduce the complexity and size of code required to implement iterative algorithms. This article will explain how VIs can be called recursively in LabVIEW 2009 or later. There are several well-known algorithms that are commonly implemented using recursion, including a binary tree, a Fibonacci sequence, or the calculation of a factorial, as shown below. A reentrant VI can be placed onto its own block diagram for use in a recursive algorithm by dragging the icon of a VI to its own block diagram.

 

Requirements

Software:

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

1. Enter the order of Fibonacci series.
2. Run VI.
3. Observe the Fibonacci numbers at the indicator.

 

Additional Information or References

 

2012.png

 

**This document has been updated to meet the current required format for the NI Code Exchange.*

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.