Solution to Project Euler