Euler Project Problem 12