Another solution to Project Euler's problem 1