Project Euler, Problem 42, Java