Simple numbers problem implemented in Java 7