Project Euler solution for problem 1