Problem 2 from Project Euler