Improving the Algorithm
Last updated at October 28, 2026 by Teachoo
Transcript
Summary of how we improved gcd Algorithm Stage | What we do | What we avoid Original method | Build two divisor lists, then a common-divisor list | — Combine scans | Check each candidate against both inputs in one scan | Two separate scans Find common divisors directly | Store only candidates dividing both inputs | Separate divisor lists and later list comparison Stop at the smaller input | Check only up to min(m, n) | Candidates that cannot be common divisors Remove the list | Store only the greatest common divisor found so far | Storing every common divisor The final method uses less storage and avoids unnecessary stages. However, it still checks every candidate up to the smaller input. This remaining limitation motivates the later algorithms in the chapter.