2.5.8 · D4Number Theory (Intermediate)

Exercises — Extended Euclidean algorithm

2,517 words11 min readBack to topic

Level 1 — Recognition

Recall Solution 1.1

The base rows never involve division — they just record " is one copy of " and " is one copy of ". Check the meaning: ✓ and ✓.

Recall Solution 1.2

The gcd is the last non-zero remainder, so . The Bézout coefficients come from that same row: , giving . (This is exactly the "stop at the right row" rule — never the zero row.)


Level 2 — Application

Recall Solution 2.1

Quotients: , , , , . Result: , with . Check: ✓.

Recall Solution 2.2

We want with . Run Extended Euclidean on — the coefficient of in is the inverse.

coeff of coeff of

So . The coefficient of is . Reduce mod : . Answer: . Check: ✓.


Level 3 — Analysis

Recall Solution 3.1

A solution exists iff divides the right side. From 2.1, , and (since ), so solutions exist. We already have the Bézout combination . Multiply the whole equation by : Particular solution: . Check: ✓.

Recall Solution 3.2

Once one particular solution is known, all solutions come from sliding along the line while staying on integers. The step sizes are and where : Why these steps? Adding to adds to the left; subtracting from subtracts . Since , the two changes cancel — the equation still holds. Using (not ) guarantees we hit every integer solution, not just some. Check at : ; ✓.


Level 4 — Synthesis

Recall Solution 4.1

Write from the first congruence. Substitute into the second: We need . Extended Euclidean on :

coeff of coeff of

So , hence . Then , so . Check: ✓; ✓. And .

Recall Solution 4.2

. Extended Euclidean on :

coeff of coeff of

. Coefficient of is ; reduce: . Answer: . Check: ✓.


Level 5 — Mastery

Recall Solution 5.1

A congruence has solutions iff divides ; then there are exactly solutions mod . Here : , and ✓ — so 2 solutions exist. Divide everything by : . Now , so invert . Extended Euclidean on :

coeff of coeff of

, so . Then . The two solutions mod are and . Check: ✓; ✓. Answers: .

Recall Solution 5.2

Let = number of big jumps, = number of small jumps. Landing on means (a) Possible? This is a Diophantine equation . Solvable iff . Since , yes. Extended Euclidean on :

coeff of coeff of

. So and (matching ) . (b) General solution: since , and (both must stay ; increasing from only grows them, decreasing sends negative at : ). The smallest non-negative is at . Answer: big jumps and small jumps. Check: ✓. See the jump-line figure below.

Figure — Extended Euclidean algorithm

Recall Self-test summary (cloze)

The gcd is the last non-zero remainder, and its Bézout coefficients live in that same row. A congruence is solvable iff ::: divides . To turn a Bézout solution of into a solution of , you ::: multiply the whole equation (and both coefficients) by . The general Diophantine solution steps by ::: and by . A negative inverse coefficient is fixed by ::: adding until it lands in .


Connections