#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::TAOCP Vol 2::4.5.2 The Greatest Common Divisor
#columns:Front	Back	Tags
TAOCP §4.5.2 The Greatest Common Divisor: what does it cover?	Euclid again, now in depth: the extended algorithm for finding coefficients, the binary gcd algorithm that uses only shifts and subtraction, and gcd for multiple-precision numbers.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.5.2 cracked.guide::kind::about
TAOCP §4.5.2: why does it matter?	Extended Euclid gives modular inverses, needed in RSA and hashing. Binary gcd is a good example of trading division for cheap operations.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.5.2 cracked.guide::kind::why
TAOCP §4.5.2: what traps should you watch for?	<ul><li>Sign handling in extended Euclid coefficients.</li></ul>	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.5.2 cracked.guide::kind::traps
TAOCP §4.5.2, exercise 9 (rated 18): what is it asking?	Run the binary gcd and extended Euclid by hand on one pair.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.5.2 cracked.guide::kind::exercise
TAOCP §4.5.2, exercise 16 (rated M22, recommended): what is it asking?	Division modulo m with extended Euclid. Modular inverse in practice.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.5.2 cracked.guide::kind::exercise
TAOCP §4.5.2, exercise 17 (rated M20, recommended): what is it asking?	Lift an inverse modulo 2^e to modulo 2^(2e). Newton's method for integers.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.5.2 cracked.guide::kind::exercise
TAOCP §4.5.2, exercise 41 (rated M22): what is it asking?	Closed form for gcd(10^m - 1, 10^n - 1).	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.5.2 cracked.guide::kind::exercise
TAOCP §4.5.2, exercise 5 (rated M26, recommended): what is it asking?	Design a gcd algorithm for balanced ternary.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.5.2 cracked.guide::kind::exercise
TAOCP §4.5.2, exercise 39 (rated M28, recommended): what is it asking?	Extend the binary gcd to compute the coefficients too.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.5.2 cracked.guide::kind::exercise
TAOCP §4.5.2, exercise 40 (rated M25, recommended): what is it asking?	A hardware-friendly binary gcd that avoids comparisons.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.5.2 cracked.guide::kind::exercise
TAOCP §4.5.2, exercise 10 (rated HM24, recommended): what is it asking?	Prove that two random integers are coprime with probability 6/pi^2. The stretch.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.5.2 cracked.guide::kind::exercise
TAOCP §4.5.2: how many exercises, and how are they rated?	42 exercises, rated 18 to HM49.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.5.2 cracked.guide::kind::exercises
TAOCP §4.5.2: what should you be comfortable with first?	<ul><li>1.1 Algorithms</li><li>4.5.1 Fractions</li></ul>	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.5.2 cracked.guide::kind::prereqs
TAOCP §4.5.2: how should you work through it?	Implement Euclid, binary gcd and extended Euclid. Benchmark the first two on 64-bit numbers. Use extended Euclid to compute modular inverses and check them.	cracked.guide cracked.guide::phase::taocp-2 cracked.guide::section::4.5.2 cracked.guide::kind::approach
