I’m using the fractions module in Python v3.1 to compute the greatest common divisor. I would like to know what algorithm is used. I’m guessing the Euclidean method, but would like to be sure. The docs (http://docs.python.org/py3k/library/fractions.html?highlight=fractions.gcd#fractions.gcd) don’t help. Can anybody clue me in?
I’m using the fractions module in Python v3.1 to compute the greatest common divisor.
Share
According to the 3.1.2 source code online, here’s
gcdas defined inPython-3.1.2/Lib/fractions.py:So yes, it’s the Euclidean algorithm, written in pure Python.