Project Euler, Problem 23, Java