Solution for ProjectEuler Problem 6