Skip to content
← All questions

What is the base case for the Euclidean algorithm?

The base case for the Euclidean algorithm is when the second argument of the pair is zero. At this point, the algorithm stops, and the first argument is returned as the greatest common divisor.

Conditions

  • The algorithm is in the process of replacing pairs using gcd⁡(a,b)=gcd⁡(b,a mod b)\gcd(a,b)=\gcd(b,a\bmod b).
  • The second argument bb has reached zero.

Reasoning, step by step

  1. Monitor the second argument of the current pair.
  2. Check if the second argument is zero.
  3. If it is zero, terminate the algorithm.
  4. Return the first argument as the result.

Example

Stop at the zero second argument rather than attempting a remainder with a zero divisor.

Common misconceptions

  • Thinking that the base case is when both arguments are zero.
  • Believing that the algorithm continues until the first argument is zero.

Watch the explanation

Connected concepts

Explore next

Related questions

Meet the concept

↗
Find a method

↗
Meet the concept

↗
Find a method

↗
Find a method

↗

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