Problem 2 of Project Euler