Answer Project Euler question #10