title: While loop that will cycle through entries in array java
body: <p>Alright so I'm trying to set up a program that will find prime numbers. I've set up an array called primes with prime numbers up to 199. How can I create a while loop that pretty much says, while (x%primes[any number in primes] &lt;= 0). I'm not sure what I should be putting to make it properly detect it. I know or statements are an option, I'm just wondering if there's a better way. Here's my code:</p>
  
  <pre><code>import static java.lang.System.out;
  public class Problem3 {
  
  public static void main(String[] args) {
      /// What is the largest prime factor of the number 600851475143 ?
          long x;
          x = 600851475143L;
          int[] primes = {
              2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199,
          };
          out.println(x);
          //while (x % primes[*This is where I need clarification*] &lt;= 0) {
              int i = 0;
  
                  for (i = 0; i &lt; primes.length; i++) {
                      //out.println("Term " + i + " is " + primes[i]);
                          if (x%primes[i] &lt;=0) {
                              x = x/primes[i];
                          }
  
                  }   
          //}
  
          out.println(x);
  
  }
  
  }
  </code></pre>
  
  <p><a href="https://stackoverflow.com/a/53968072/10845696">This answer worked for me!</a></p>