Visual walkthrough — Extended Euclidean algorithm
Before any symbol appears: here is the whole idea in one sentence. We chop a big number down using a small number over and over; and at every chop we quietly write down "how much of the big number and how much of the small number are hiding inside this leftover piece."
Throughout, and are non-negative integers (zero or positive whole numbers — no negatives), and for the very first division we need so we actually have something to divide by. The single truly undefined corner, , is dealt with head-on in Step 7.
Step 1 — What "divide with remainder" really means
WHAT. With , : fit as many 15s into 56 as possible. Three of them: . Left over: . So , .
WHY this operation and not, say, subtracting once? Because dividing does all the repeated subtractions in a single stroke. Subtracting 15 from 56 three times is the same as ; the quotient just counts how many times.
PICTURE. The bar of length 56 is covered by three teal blocks of 15, and one leftover orange stub of length 11 pokes out.

Step 2 — The chain of remainders (this is the Euclidean Algorithm)
WHAT. For and :
The last non-zero remainder is , so .
WHY it must terminate. Each remainder is strictly smaller than the one before ( from Step 1). A strictly decreasing sequence of non-negative whole numbers can't go forever — it is forced to hit .
WHY the last non-zero remainder is the gcd. Let us give a name to the star of the argument: write for the last non-zero remainder — the final produced before the algorithm first hits (here ). Now the "see why" argument as a picture-friendly chain. Suppose a number divides both and . Look at the first line , rewritten as . Since divides and divides , it divides too — so divides . Now divides and , so by the same argument it divides the next remainder, and so on down every line. The implication marches all the way to the bottom:
Reading the chain upward does the reverse: the last non-zero remainder divides the one above it (the line where its multiple gives remainder ), which divides the next, all the way back up to and . So both divides and is divisible by every common divisor — that is exactly what "greatest common divisor" means.
PICTURE. A descending staircase of shrinking bars: . Each step's leftover becomes the next step's divisor (arrow pointing down-left).

Recall The divisibility chain in one line
Why does a common divisor of survive to the last non-zero remainder ? ::: Because : if splits and cleanly it also splits their combination , and this repeats on every line, so divides every remainder down to the last non-zero one — which is the gcd.
Step 3 — The key idea: every leftover is a recipe in and
WHAT. Look at the very first leftover: . Rewrite it as So the recipe for is : one copy of , minus three copies of .
WHY track this? Our goal is to write itself as . If every leftover carries such a recipe, then the last non-zero leftover — the gcd — arrives with its recipe already built. No backtracking needed.
PICTURE. The orange stub of length 11 is shown as "one full 56-bar, with three 15-blocks scrubbed away (hatched out)." Its recipe label reads .

Step 4 — The two seed recipes (the base cases)
WHAT. gets the tag ; gets the tag .
WHY these exactly? is trivially "one copy of and zero copies of ." These are the identity recipes — nothing has been mixed yet. If you skip them and start tagging only from the first division, the recurrence has nothing to feed on and collapses.
PICTURE. Two starting cards. Card : a full -bar labelled . Card : a full -bar labelled . These are the coordinate axes of everything that follows.

Step 5 — The recurrence: how a new recipe is born
WHAT. The identical arithmetic that made the new remainder () also makes the new recipe — you just run it separately on the -column and the -column.
WHY it works. A recipe is linear: if has recipe and has , then has recipe . Subtraction and scaling of -combinations stay -combinations. This is the whole engine.
PICTURE. Three columns — remainder, , — each computing "two positions back minus times one position back" with the same coloured arrows. The remainder column and the column and the column are visibly the same shape of arrow.

Step 6 — Run it: watch the recipes evolve to the gcd
WHAT. Start from the seeds and and apply Step 5 down every division line. The two seed rows (, ) show "—" in the quotient column because no division has happened yet — they are the starting values, not results of a division, so there is no to record. The first real quotient, , appears on the line that creates the first leftover .
| recipe check | |||||
|---|---|---|---|---|---|
| — (seed, no division) | |||||
| — (seed, no division) | |||||
| stop | stop | — |
WHY stop at , not ? The gcd is the last non-zero remainder. The row has remainder ; the answer lives one row up, at : .
WHY the parentheses on signs? At we needed but earlier . Writing the one-position-back value inside brackets with its sign stops the classic sign flip.
Result.
PICTURE. The staircase from Step 2 re-drawn, but each stair now carries its evolving card, and the rightmost check column shows landing back on the remainder every time — proof the invariant never breaks.

Step 7 — Edge and degenerate cases (never get surprised)
WHY show all five? If you only ever practise the "nice" case, the swap, the instant- remainder, or the trap look like bugs. They aren't — the same recurrence handles A–D with zero special-casing, and E is guarded out at the door.
PICTURE. Five small panels, one per case, each showing the (very short) staircase and the final recipe card, with the panel flagged as excluded.

The one-picture summary
Everything at once: the divisions on the left build the shrinking remainders; the recipe cards on the right ride along, each computed by "two positions back minus times one position back"; and at the bottom the last non-zero remainder emerges wearing its recipe , giving Bézout: .

Recall Feynman: the whole walkthrough in plain words
Line-em-up two numbers, 56 and 15. Keep fitting the smaller into the bigger and looking at the crumb left over — 11, then 4, then 3, then 1, then it fits perfectly and there's no crumb. The last real crumb, 1, is the gcd.
The clever extra bit: every crumb secretly remembers "I'm made of this many 56s and this many 15s." The first crumb 11 is "one 56 take away three 15s." Because each new crumb is built by the same subtraction from the two crumbs before it, its recipe is built by the very same subtraction on their recipes. So when the final crumb 1 shows up, it already knows it's " copies of 56 plus copies of 15." That's — which is why one line of arithmetic gives you inverses, Diophantine solutions, and RSA keys.
Connections
- Euclidean Algorithm — the plain version we extended in Step 2
- Bézout's Identity — the result the recipes prove
- Modular Multiplicative Inverse — Case C: the coefficient is the inverse
- Linear Diophantine Equations — scale the recipe to solve
- Chinese Remainder Theorem — glues congruences using these inverses
- RSA Algorithm — private key from