Euler Project Problem 9