LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

displaying prime numbers in array indicator

hello there,

Can anyone tell me how do i display the prime numbers in an array indicator ?

My VI just tells only if the number is prime or not

 

Thank you

 

Regards,

Akshay

0 Kudos
Message 1 of 3
(2,388 Views)

Hi akshay,

 

Can anyone tell me how do i display the prime numbers in an array indicator ?

By putting your VI into a loop (to test more than just one number) and using autoindexing…

 

My VI just tells only if the number is prime or not

In a very Rube-Goldberg way…

Why do you divide by 1?

Why do you divide by every number, starting from 2? (Example: you don't need to test for "4" when you already tested for "2"…)

Why do you divide just 10 times (for divisors upto 10)?

Why don't you use the iteration condition in the FOR loop once you know the number is no prime?

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(2,382 Views)

Hello,

 

https://forums.ni.com/t5/Example-Program-Drafts/Prime-number-Array-of-quot-n-quot-elements/ta-p/3669...

 

Check this Link, u can get some idea regarding getting Prime number 

0 Kudos
Message 3 of 3
(2,347 Views)