static boolean isPrime(int toTest){ if(toTest!=2&&toTest%2==0){ return false; } if(toTest == 1||toTest == 0){ return false; } for(int i = 3, limit=(int)Math.sqrt(toTest);i<=limit;i+=2){ if(toTest%i==0) return false; } return true; }