Complete problem 2 of Project Euler