~/ learn/ comp-372/ cards/ Number-Theoretic Algorithms
1 of 13

Type EUCLID (the GCD recursion theorem made into an algorithm)

Type EUCLID (the GCD recursion theorem made into an algorithm)

Answer

EUCLID(a, b) if b == 0 return a return EUCLID(b, a mod b)

gcd(a,b) = gcd(b, a mod b); the second argument strictly shrinks each call, and gcd(a,0)=a is the base case. O(lg b) calls (Lamé).

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/dd141d6f-e861-4d7c-8ed6-3f8842c16b4a/flashcard utf-8 LF