Project Euler, Problem 52, Java