I recently was part of a small java programming competition at my school. My partner and I have just finished our first pure oop class and most of the questions were out of
Using BigInteger.isProbablePrime(certainty) and BigInteger.nextProbablePrime() can significantly cut down the number of cases you need to check quite efficiently