Euclid's Algorithm

Recall that we are interested in computing the GCD of two non-negative integers: the largest number that divides both numbers evenly.

Euclid's algorithm computes the GCD of a and b by returning a if b=0 and otherwise returning the GCD of b and tex2html_wrap_inline162 .

Here is an animation to illustrate this process and also to help make it clear why it computes the correct answer.


next up previous
Next: Efficiency Analysis Up: EUCLID'S ALGORITHM Previous: EUCLID'S ALGORITHM