To download NI software, including the products shown below, visit ni.com/downloads.
Overview
It can sometimes be useful to recursively call a function in programming.
This is possible in LabVIEW, putting a VI on its own block diagram.
Description
Start with any natural number (positive integer).
If the number is even, divide by 2.
If the number is odd, multiply by 3 and add 1.
Repeat. Stop if you reach a value of 1.
The Collatz Conjecture states that any starting number will eventually end up at 1, but it remains unproven.
This VI will return the path length for any integer.
Requirements
Steps to Implement or Execute Code
Additional Information or References
VI Block Diagram
**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.