Jump to content

Need to Solve Two Problems


Recommended Posts

I am trying to solve two problems...

what is the best way to solve problems like....

1. i want to make one VI that like I rolls 25 times die and need to count each of numbers in one array....like 1 is generated 10 times and so on....

What I did?... I had make one array in which i generate random numbers in between 1 to 6..now i would like to separate or count the each numbers....

plz dont say that this example is given in solution 1....i dont want to see in solution...i need help from the members....atleast give me a hint...how to solve the problem....

2. In which i would like to generate Prime Number in range of 0-500 and set that numbers in one array whose answer is 100 when i multiplicate that prime number using 3...

for example...If i get 37 as a prime number than it will set in 1 index bz its multiplication with 3 gives me more than 100 number....

I request members that plz give me a hint to solve the problems...I m in try to solve the problem bz I have completed only B1...i required your help....

Sahara

Link to comment

QUOTE(sahara agrasen @ Oct 19 2007, 09:23 AM)

2. In which i would like to generate Prime Number in range of 0-500 and set that numbers in one array whose answer is 100 when i multiplicate that prime number using 3...

for example...If i get 37 as a prime number than it will set in 1 index bz its multiplication with 3 gives me more than 100 number....

Isn't that a lot like just finding all the prime numbers between 33 and 500? Am I misunderstanding something? :wacko:

I'd do something like this (assuming you can't just start with a pre-cooked list of primes, which would kind of defeat the purpose):

  1. Initialize an empty array, which we'll call "Known Primes"
  2. For each i from 2 to 500 (because i=0 and i=1 are degenerate)
  3. Divide i by each element of "Known Primes" which is less than or equal to sqrt(i). If none of the results are integer values, then i must be prime, so add it to the "Known Primes" list. If any of the results is an integer, then i is not prime, so don't add it to the "Known Primes".

I'm not totally sure that will work, but I think it should. I'm not going to test it for you. You're already lucky enough that I like prime numbers.

Link to comment

In Java2 I had to write a program similar to this with the prime numbers and I did it the same way Justin suggested.

As for how many 1's, or 2's or 3's are rolled, there is an OpenG sub-VI in the array tools which is search array, and it will return the indices in an array form. You could search the array for "1" and the size of the array of indices out is the number of 1's that are in the array. (I hope this is easily understandable)

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.