problem 8 solution, 0.001321 seconds