Duplicate post. Please don't do this, it is ultimately a time waster. Go to the other Topic and delete it before some one replies to it. If they have, direct them to answer this Topic.
You need a nested loop: the outer one to process the array, the inner one to do all the numbers up to the number in question, with a limit of sqrt(n).
This is the typical naive approach and is very inefficient, ok for a small limit though. The problem is when a number is prime,
all the numbers before it are checked. When another prime is encountered (which may only be a small amount higher than the previous one)
all those numbers are checked
again.
A better approach is to remove multiples of prime numbers form a list, as in multiples of 2,3,5,7 etcetera. The next multiple to check for is the next number in the list. So remove multiples of 2, then 3, then the next is 5 because 4 is gone already. An improvement is to start from the square of the number. So if you are doing multiples of 5, start at 25 because all the numbers up to there are already prime.
Good Luck !!