Project Euler, Problem 30, Java