Project Euler implemented in Java