Java: Prime number checker