Euler Project Problem 8