Prime Number generator in Java