Project Euler, Problem 22, Java