Euclidean Algorithm

Context: FIT1058_MOC · computes gcd by repeated reduction · subtraction sped up to remainder · extended to find Bézout coefficients

Quick Revision

  • 🎯 Objective: compute by iterating ➔ stop when , output .
  • 📦 Core Components: reduction base case ➔ quotient saved for Extended Euclidean Algorithm.
  • ⚡ Key Constraint: remainder form collapses subtractions into one ; terminates as strictly decreases.

📝 Core

1. The Reduction (Subtraction → Remainder)

  • Identity (Greatest Common Divisor reduction theorem).
  • Speed-up ➔ replace repeated with a single .
  • Base caseoutput .

2. Why It Works & Halts

  • Correctness ➔ each step preserves the pair’s common divisors ⟹ final divisor = original .
  • Termination ➔ second argument strictly decreases and stays ⟹ must reach .
  • Quotient saved recorded ➔ reused by Extended Euclidean Algorithm for Bézout .

Key identities:

⚖️ Core Decision Matrix

FormStep costWhen it hurts
Subtraction subtractions to one remainderhuge quotient ⟹ many steps
Remainder one modulo per stepnone — the efficient form
Extendedremainder + a Bézout tripleslightly more bookkeeping

When It Flips: the remainder form runs in divisions (worst case: consecutive Fibonacci numbers). It is the standard test for Coprimality () and, extended, computes modular inverses.

📊 Exam Execution Trace

Manual Execution Trace

, iterating :

Step / State
0 (Init)252198
1252198154
219854336
35436118
4361820 →

⚠️ Common Mistakes

  • 💡 Keep going until , don’t stop at the first small remainder ➔ the answer is the last divisor, not the last remainder; and record if the Bézout coefficients are wanted.

🧠 Active Recall