Java Prime Number need to be faster
<pre><code>import java.util.*;

public class PrimeNum {
public static void main(String[] args) {
    Scanner input = new Scanner(System.in);     
    int a = input.nextInt();
    int b = input.nextInt();

    for(int i = a ; i &lt;= b ; i++ ) {
        if ( i == 2 || i == 3 ) System.out.println(i);

        for(int j = 2; j &lt;= (i / 2) ; j++ ) {
            if ( (i % j) == 0 ) break;
            if ( j == (i / 2) ) System.out.println(i);
        }
    }

}
}
</code></pre>

<p>This program is simple, type in 2 int a and b. It will find any Prime Number within a and b.</p>

<p>How can I make this faster ?. I tried the Math.sqrt one but it does not work well in this case :( I do not really know because whenever I use it, it causes a lot of bugs. I would love to see someone use Squareroot in this case.</p>
