Solution to Problem 1 of Project Euler