Dynamic Programming21 sections · 916 units
Open in Course

Challenge: Trace GCD

Manual recursion exercise

Before moving on, trace GCD(4848, 1818) by hand. Write down each recursive call and the values of aa and bb. Start: GCD(4848, 1818). What is 48mod1848 \mod 18? That becomes the new bb.

What is the new aa? Keep going until you hit the base case. Check your answer: the sequence should be GCD(4848, 1818) → GCD(1818, 1212) → GCD(1212, 66) → GCD(66, 00). The answer is 66. If you got this right, you understand how GCD shrinks toward the base case. If not, re-read the GCD units.