2.5.8 · D1Number Theory (Intermediate)

Foundations — Extended Euclidean algorithm

2,618 words12 min readBack to topic

Before we can even read the parent note, we need to earn each piece of its vocabulary. We go one symbol at a time, and nothing is used before it is drawn.


0. Two operators we lean on: (add) and (order)

The picture: everything is just which side of the other a point sits on the same line we draw next. We name these now because every later rule ("the remainder satisfies ") is spoken in this language.


1. Whole numbers and the number line

The picture is a number line: evenly spaced ticks stretching left and right forever. Positive numbers step right, negative numbers step left, zero sits in the middle.

Figure — Extended Euclidean algorithm

Why the topic needs it. Everything in this chapter — remainders, coefficients, gcds — lives on this line. When we later write , that is just "walk 4 steps left of zero". The letters that fill the parent note are all integers; they are all just chosen points on this line.


2. Letters standing for numbers: , , ,

The picture: think of and as two labelled tokens sitting on the number line. In the parent note:

  • and are the two numbers we start with (e.g. and ).
  • and are the two answers we are hunting for — how many copies of and of to combine.

Why the topic needs it. The whole point is a general recipe that works for any starting pair. Naming the pair lets us state one formula instead of redoing arithmetic for every example.


3. Multiplication as repeated stacking, and

The picture: a stack of equal-length jumps along the number line. is three jumps of length to the right; is two jumps of length to the left.

Figure — Extended Euclidean algorithm

Why the topic needs it. The star formula the parent note chases — a linear combination that equals the gcd (defined next in §4) — is exactly this shape . The entire algorithm is a machine for finding the two coefficients and . If "linear combination" is fuzzy, the goal is invisible.


4. Divides, common divisor, and

The picture: measure two sticks of length and with the same ruler. A common divisor is any ruler-spacing that fits both sticks a whole number of times. The gcd is the longest such spacing — the biggest tile that paves both sticks perfectly.

Figure — Extended Euclidean algorithm

Why the topic needs it. is the target the algorithm computes and the right-hand side of Bézout's identity. See Euclidean Algorithm for the plain version that finds only this number.


5. Quotient and remainder:

This is the heartbeat of the whole algorithm, so we build it carefully.

The picture: pour into buckets each holding . You fill full buckets; the puddle that can't fill another bucket is .

Figure — Extended Euclidean algorithm

Why the topic needs it. Every single row of the Extended Euclidean table is one division equation. The subscripted symbols and below are just this same step, repeated.


6. Subscripts, the remainder chain, and the coefficient sequences

The picture: a row of numbered lockers. is "whatever is in locker ". is "the locker just before "; is "two lockers before ".

Where the chain starts. We seed the two lockers before any division happens: Then each new locker is the remainder of dividing the two before it, using §5's equation , i.e.

Now the two coefficient sequences. For each locker we also track how that remainder is built from and . We define two number sequences and by the requirement Their starting values fall straight out of the seeds:

  • .
  • .

Why the recurrence follows. Each new remainder is literally the same subtraction we do on the numbers — we just perform it on their recipes instead. The coefficients obey the exact same "two-lockers-ago minus times one-locker-ago" rule because that is the only operation happening. That is the whole engine of the Extended algorithm.

Why the topic needs it. The parent note's recurrence is now grounded: you know what is (the -coefficient of locker ), where it starts (), and why the formula holds (it inherits the remainder subtraction).


7. Congruence and (for the applications)

The picture: a clock with marks. Walking steps and walking steps land you on the same mark. On a -hour clock, .

Why the topic needs it. The parent note's applications — Modular Multiplicative Inverse, RSA Algorithm — live on this clock. From you read : on the mod- clock, the term wraps all the way around and vanishes, leaving landing on mark . That is why the coefficient is the inverse.


How these foundations feed the topic

Add plus minus and order less greater

Integers on a number line

Letters a b x y

Divides and gcd

Linear combination a x + b y

Quotient and remainder a = q b + r

Subscripts and remainder chain

Euclidean algorithm finds gcd

Coefficient sequences x i and y i

Bezout identity a x + b y = gcd

Modular inverse mod m

Congruence mod m

RSA and Diophantine equations

Read top to bottom: add/order and the number line give us letters and linear combinations and the gcd; division-with-remainder plus subscripts give us the plain Euclidean algorithm; tracking coefficient sequences through it gives the extended version, which produces Bézout's identity, which powers the mod- applications.


Equipment checklist

Cover the right side and answer each before opening the parent note.

What does mean on the number line?
sits to the left of .
What is an integer, in one phrase?
Any whole number — positive, negative, or zero — with no fractional part.
What does mean in plain words?
Copies of laid end to end hit exactly, no leftover.
What is , and what is ?
The largest number dividing both and (taken nonnegative); .
What is a linear combination of and ?
Any number of the form using integer coefficients .
In , what are and , what constraint does obey, and what may never be?
is how many whole copies of fit in ; is the leftover with ; may never be .
Is equal to ?
No — the subscript is an address ("second remainder"), not a multiplier.
What are the seed values and the coefficient seeds ?
with , and with .
Why does hold?
Because , and substituting each remainder's recipe pushes that same subtraction onto the coefficients.
Why does the remainder chain eventually reach ?
Because each remainder is strictly smaller than the previous (), so they shrink and must hit .
What does say on a clock?
On the -mark clock, copies of land exactly on mark .

Connections