Improved speed of pythagorean, updated 039.py