Solution to Project Euler Problem 6