a quick gcd algorithm