04-14-2010 04:31 PM
Hello,
I'm new to labview....
I'm trying to create a vi that takes a number n, and outputs all of the prime numbers from 0 to n (i.e. including 1).
My approach to do it is using a formula node, but I can't figure out how to index the array or to output every prime number.
It seems that my indexing algorithm works fine, but I'm just pushing it to the array as an element.
It'll will be great if anyone could take a look at my vi, and give me a hint on how to index properly.
Thank you,
AA
Solved! Go to Solution.
04-14-2010 07:58 PM
Why not do this in pure LabVIEW code?
You are only putting in a single number, and outputing scalar numbers of prime and index. If you want to search for more numbers, you are going to need to put this whole thing in a while loop and feeding multiple numbers in at number an autoindexing output of your 1-D array into a 2-D array at the tunnel of your loop.
04-14-2010 08:14 PM - edited 04-14-2010 08:15 PM
In the end I've created a hybrid of code and labview. It's far from being the most efficient code, but it works.
I thought, probably wrong though, that doing it with pure LabVIEW code will complicate things. I don't control it very well yet, and I didn't know how to set up counters/index.
04-14-2010 08:22 PM - edited 04-14-2010 08:25 PM
your output needs to be an array, and to index it use prime[index]
also you need to declare index and prime[]
04-14-2010 08:25 PM