My solution to Project Euler problem 12