Согласно исходному коду 3.1.2 онлайн , здесь gcd
, как определено в Python-3.1.2/Lib/fractions.py
:
def gcd(a, b):
"""Calculate the Greatest Common Divisor of a and b.
Unless b==0, the result will have the same sign as b (so that when
b is divided by it, the result comes out positive).
"""
while b:
a, b = b, a%b
return a
Так что да, это евклидов алгоритм, написанный на чистом Python.