Skip to content
← All questions

When does the Euclidean algorithm using division terminate?

The Euclidean algorithm using division terminates when one of the entries in the current pair (a,b)(a,b) becomes zero. Specifically, when the remainder rr in the step b=aq+rb=aq+r becomes zero, the next pair is (0,a)(0,a) or (a,0)(a,0), and the algorithm stops, returning the non-zero entry as the gcd.

Conditions

  • The algorithm uses the step gcd⁡(a,b)=gcd⁡(b,a mod b)\gcd(a,b) = \gcd(b, a \bmod b).
  • aa and bb are nonnegative integers.
  • Termination occurs when the second argument is 0.

Reasoning, step by step

  1. Perform the division step to get the remainder.
  2. Check if the remainder is zero.
  3. If the remainder is zero, the algorithm terminates.
  4. The gcd is the other number in the pair (the divisor from the previous step).
  5. If the remainder is not zero, continue with the new pair.

Example

The script states: 'Continue until one entry is zero; the other is the gcd.'

Common misconceptions

  • Believing that the algorithm terminates when the numbers are equal.
  • Thinking that the algorithm runs for a fixed number of steps regardless of input.
  • Confusing the termination condition with the base case definition gcd⁡(n,0)=n\gcd(n,0)=n.

Watch the explanation

Connected concepts

Explore next

Related questions

Understand why

↗
Find a method

↗
Find a method

↗
Understand why

↗

Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.