nextPossibility: for (int possiblePrime = n+1; ; possiblePrime++) {
// watch for overflow
if (possiblePrime < 0) throw new IOException("Arithmetic Overflow");
for (int factor = 2; factor <= Math.sqrt(possiblePrime); factor++) {
if (possiblePrime % factor == 0) continue nextPossibility;
}
return possiblePrime;
}