Answer to Project Euler in Python