Skip to content
← All questions

How does the Euclidean algorithm keep the GCD while replacing the pair of numbers?

The Euclidean algorithm keeps the GCD by repeatedly applying the step gcd⁡(a,b)=gcd⁡(b,a mod b)\gcd(a,b)=\gcd(b,a\bmod b) for nonnegative aa and positive bb. This replaces the pair with the divisor and the remainder, preserving the greatest common divisor.

Conditions

  • aa is a nonnegative integer.
  • bb is a positive integer.
  • The operation a mod ba\bmod b computes the remainder of aa divided by bb.

Reasoning, step by step

  1. Start with a pair of nonnegative aa and positive bb.
  2. Compute the remainder of aa divided by bb.
  3. Replace the pair (a,b)(a,b) with (b,a mod b)(b, a\bmod b).
  4. Repeat the process until the second argument is zero.

Example

For nonnegative aa and positive bb, the Euclidean step is gcd⁡(a,b)=gcd⁡(b,a mod b)\gcd(a,b)=\gcd(b,a\bmod b). The remainder is smaller than bb, which makes repeated steps terminate.

Common misconceptions

  • Believing that the remainder can be larger than or equal to the divisor.
  • Thinking that the algorithm requires both numbers to be positive at every step, ignoring the base case where the second argument becomes zero.

Watch the explanation

Connected concepts

Explore next

Related questions

Meet the concept

↗
Meet the concept

↗
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.