Skip to content
← All questions

How does the Euclidean algorithm compute the greatest common divisor of two natural numbers by repeated division?

The Euclidean algorithm computes the greatest common divisor by repeatedly applying the division algorithm. Starting with two natural numbers aa and bb, you divide the larger by the smaller to get a quotient and a remainder. You then replace the pair with the previous divisor and the new remainder. This process repeats until the remainder is 0. The last nonzero remainder is the greatest common divisor.

Conditions

  • The inputs aa and bb are natural numbers.
  • The division algorithm is applied repeatedly.
  • The process stops when a remainder equals 0.

Reasoning, step by step

  1. Start with two natural numbers aa and bb.
  2. Apply the division algorithm: a=bq1+r1a = bq_1 + r_1.
  3. Replace the pair (a,b)(a, b) with (b,r1)(b, r_1).
  4. Apply the division algorithm again: b=r1q2+r2b = r_1q_2 + r_2.
  5. Continue this process, generating a sequence of remainders r1,r2,…r_1, r_2, \dots
  6. Stop when a remainder rnr_n is 0.
  7. Identify the last nonzero remainder rn−1r_{n-1} as gcd⁡(a,b)\gcd(a, b).

Example

To find gcd⁡(5295,4321)\gcd(5295, 4321), the algorithm proceeds as follows: 5295=1⋅4321+9745295 = 1 \cdot 4321 + 974 4321=4⋅974+4254321 = 4 \cdot 974 + 425 974=2⋅425+124974 = 2 \cdot 425 + 124 425=3⋅124+53425 = 3 \cdot 124 + 53 124=2⋅53+18124 = 2 \cdot 53 + 18 53=2⋅18+1753 = 2 \cdot 18 + 17 18=1⋅17+118 = 1 \cdot 17 + 1 17=17⋅1+017 = 17 \cdot 1 + 0 The last nonzero remainder is 1, so gcd⁡(5295,4321)=1\gcd(5295, 4321) = 1.

Common misconceptions

  • Believing the algorithm stops at the first remainder of 1; it must continue until the remainder is 0 to formally satisfy the stopping condition, although reaching 1 already implies the gcd is 1.
  • Confusing the quotient with the remainder; the next step uses the remainder, not the quotient.
  • Thinking the algorithm requires the numbers to be prime; it works for any natural numbers.

Watch the explanation

Connected concepts

Explore next

Related questions

Understand why

↗
Find a method

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