This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 6.042/18.062J Mathematics for Computer Science September 22, 2010 Tom Leighton and Marten van Dijk Notes for Recitation 4 1 The Pulverizer We saw in lecture that the greatest common divisor (GCD) of two numbers can be written as a linear combination of them. 1 That is, no matter which pair of integers a and b we are given, there is always a pair of integer coeﬃcients s and t such that gcd( a,b ) = sa + tb. However, the proof was nonconstructive : it didn’t suggest a way for finding such s and t . That job is tackled by a mathematical tool that dates to sixthcentury India, where it was called kuttak , which means “The Pulverizer”. Today, the Pulverizer is more commonly known as “the extended Euclidean GCD algorithm”, but that’s lame. We’re sticking with “Pulverizer”. Euclid’s algorithm for finding the GCD of two numbers relies on repeated application of the equation: gcd( a,b ) = gcd( b, rem ( a,b )) which was proved in lecture (see the notes “Number Theory I”). For example, we can compute the GCD of 259 and 70 as follows: gcd(259 , 70) = gcd(70 , 49) since rem (259 , 70) = 49 = gcd(49 , 21) since rem (70 , 49) = 21 = gcd(21 , 7) since rem (49 , 21) = 7 = gcd(7 , 0) since rem (21 , 7) = = 7 . The Pulverizer goes through the same steps, but requires some extra bookkeeping along the way: as we compute gcd( a,b ), we keep track of how to write each of the remainders (49, 21, and 7, in the example) as a linear combination of a and b (this is worthwhile, because our objective is to write the last nonzero remainder, which is the GCD, as such a linear 1 In fact, we proved that among all positive linear combinations of the numbers their GCD is the smallest. 2 Recitation 4 combination). For our example, here is this extra bookkeeping: x y ( rem ( x,y )) = y x − q · 259 70 49 = 259 − 3 · 70 70 49 21 = 70 − 1 · 49 = 70 − 1 · (259 − 3 · 70) = − 1 · 259 + 4 · 70 49 21 7 = 49 −...
View
Full
Document
This note was uploaded on 01/19/2012 for the course CS 6.042J / 1 taught by Professor Tomleighton,dr.martenvandijk during the Fall '10 term at MIT.
 Fall '10
 TomLeighton,Dr.MartenvanDijk
 Computer Science

Click to edit the document details