2082 6

CSC325 · 2082 · 5 marks

Using Extended Euclidean Algorithm, find the GCD of 12 and 16.

Using Extended Euclidean Algorithm, find the GCD of 12 and 16. [5]

Design and Analysis of AlgorithmsChapter 7: Number Theoretic AlgorithmsNumber Theoretic Notations, Euclid's and Extended Euclid's ANumerical: Extended Euclidean algorithm

Extended Euclidean Algorithm: GCD of 12 and 16

Given

  • First integer: $a = 16$ (larger)
  • Second integer: $b = 12$

Goal: Find $\gcd(16, 12)$ and integers $x, y$ such that $16x + 12y = \gcd(16,12)$.


Solution

Forward Pass (Euclidean Algorithm)

StepDivisionQuotient $q$Remainder $r$
1$16 = 12 \times 1 + 4$14
2$12 = 4 \times 3 + 0$30

The last non-zero remainder is $4$, so:

$$\gcd(16, 12) = 4$$

Back-Substitution (Extended Part)

Express the GCD as a linear combination $16x + 12y = 4$.

From Step 1:

$$4 = 16 - 12 \times 1$$

Rearranging:

$$4 = 16 \times (1) + 12 \times (-1)$$

Therefore:

$$x = 1, \quad y = -1$$

Verification

$$16 \times (1) + 12 \times (-1) = 16 - 12 = 4 \checkmark$$

Also confirming GCD independently: divisors of 12 are ${1,2,3,4,6,12}$, divisors of 16 are ${1,2,4,8,16}$; the greatest common divisor is indeed $4$.


Result

ResultValue
$\gcd(12, 16)$$4$
Coefficient $x$ (for 16)$1$
Coefficient $y$ (for 12)$-1$
Bezout identity$16(1) + 12(-1) = 4$

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.