Example Code

Prime Finder

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

Overview

This VI will search for prime numbers based on the number of runs.

 

 

Description

Creating a program that searches for prime numbers is a good exercise for any new code developer. In the example below, the VI searches for prime numbers, and returns them in order.

 

Requirements

  • LabVIEW 2013 (or compatible)

 

Steps to Implement or Execute Code

  1. Specify the number of runs you want to code to execute.
  2. Ensure that the default values for the Initial Primes In are 1, 2 and 3.
  3. Run the program.
  4. If you wish to abort the execution, press the abort button.

 

Additional Information or References

Block diagram:
capture.JPG

 

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

 

Tim, CLD, CTD
National Instruments (UK & Ireland)
________________________________________________
"No problem is insoluble in all conceivable circumstances"

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