Example Programs

Showing results for 
Search instead for 
Did you mean: 

Calculate Prime Number in LabVIEW


Demonstrates how to calculate 1001st prime number using MathScript Node.



This program is to solve Project Euler Problem Number 7: By listing the first six prime numbers, what is the 10001st prime number? The example uses iteration number as the number to be computed. MathScript Node is used to determine whether the number is a prime number. The prime numbers identified is built into an array. The program stops when the prime numbers elements reach 1001. The last prime number will be displayed.



LabVIEW 2012 (or compatible)

MathScript RT module


Steps to Implement or Execute Code

  1. Run the program
  2. The program takes a few seconds to compute the first 1001 prime numbers
  3. The 1001st prime number will be displayed


Additional Information or Resources

VI Block Diagram



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

Rob W.