Euclid's algorithm


Definition: An algorithm to compute the greatest common divisor of two positive integers. It is Euclid(a,b){if (b=0) then return a; else return Euclid(b, a mod b);}. The run time complexity is O((log a)(log b)) bit operations.

Also known as Euclidean algorithm.

See also binary GCD, extended Euclid's algorithm, Ferguson-Forcade algorithm.

Note: After [CLR90, page 810].

Author: PEB


Worst-case behavior annotated for real time (WOOP/ADA).
Go to the Dictionary of Algorithms and Data Structures home page.

If you have suggestions, corrections, or comments, please get in touch with Paul Black.

Entry modified 2 March 2015.
HTML page formatted Mon Mar 2 16:13:48 2015.

Cite this as:
Paul E. Black, "Euclid's algorithm", in Dictionary of Algorithms and Data Structures [online], Vreda Pieterse and Paul E. Black, eds. 2 March 2015. (accessed TODAY) Available from: