Project Euler, Problem 41, 42, Java