Improves common gcd function in Python