Project Euler Solution in Python