Complete Project Euler problem 6