Subtracting 2 again and again from 99 leaves the remainder of 99 ÷ 2. So jump straight to it!
m mod n = remainder when m is divided by n. For example 17 mod 5 = 2 and 33 mod 7 = 5.
Improved algorithm:
- If m < n, swap them.
- If n = 0, the answer is m.
- Otherwise, reduce to gcd(n, m mod n).
gcd(99, 2) → gcd(2, 1) → gcd(1, 0) → 1 in just 2 reductions.
Indian mathematicians did this as a chain of long divisions, found in Āryabhaṭa's Āryabhaṭīya (499 CE). Each remainder becomes the next divisor:
- 825 = 2 × 375 + 75; 375 = 5 × 75 + 0 → gcd = 75
- 60 = 3 × 16 + 12; 16 = 1 × 12 + 4; 12 = 3 × 4 + 0 → gcd = 4
The number of reductions now grows with the number of digits, like column addition.
Tap the diagram to enlarge it
📌 Remember these
- Remainder replaces subtraction
- Last non-zero remainder = gcd
- Steps grow with digits