title: Improving 10001st prime number project
body: <p>I have been working on a Project Euler problem which is to find the 10001st prime number. I made the project in java and it gave me the correct answer. I couldn't help but notice that it had taken 17 seconds to find the answer. I am fairly new to java and I would appreciate feedback on how to improve the efficiency of my Java program - at the moment it is bruteforce. </p>
  
  <pre><code>static boolean isPrime;  
  static int primeCount;  
  static int forI = 1;  
  static int latestPrime;  
  
  public static void main(String[] args){  
      long startTime = System.currentTimeMillis();  
      while(primeCount &lt; 10001){  
          isPrime = true;  
          forI++;  
          for(int i = forI - 1; i &gt; 1; i--){  
              //If forI is divisible by another number &lt; forI, it is not prime  
              if(forI % i == 0){  
                  isPrime = false;  
              }  
          }  
          if(isPrime){  
              primeCount++;  
              latestPrime = forI;  
          }  
      }  
      long endTime = System.currentTimeMillis() - startTime;  
      System.out.println(primeCount+" "+latestPrime);  
      System.out.println("Time taken: " + endTime / 1000 + " seconds");  
  }  
  </code></pre>