Project Euler, Problem 24, Java