Recurrences and arithmetic · Definition
Greatest common divisor
Before you start you need to know
It measures how much multiplicative structure two integers share and allows us to simplify fractions and solve equations in integers.
Definition
The greatest common divisor \(\gcd(a,b)\) of two integers \(a\) and \(b\), not both zero, is the largest integer that divides both.
To find it, list the common divisors or, better, factor: take the primes present in both numbers with the smaller exponent. So \(48=2^4\cdot3\) and \(180=2^2\cdot3^2\cdot5\) give \(\gcd(48,180)=2^2\cdot3=12\). Two integers with \(\gcd(a,b)=1\) are called coprime, like 35 and 64, even though neither is prime.
Some properties are used constantly: \(\gcd(a,0)=|a|\), \(\gcd(a,b)=\gcd(b,a)\) and \(\gcd(a,b)=\gcd(a-qb,\,b)\) for any integer \(q\). The last one says that subtracting multiples of one number from the other does not change the common divisors, and it drives the Euclidean algorithm. Also, if \(d=\gcd(a,b)\), then \(a/d\) and \(b/d\) are coprime, which is why a fraction is reduced by dividing numerator and denominator by their gcd.
The gcd is also the smallest positive integer of the form \(ma+nb\) with integers \(m,n\) (Bézout's identity), which guarantees that \(ax+by=c\) has integer solutions exactly when \(\gcd(a,b)\mid c\). It relates to the least common multiple through \(\gcd(a,b)\cdot\operatorname{lcm}(a,b)=|ab|\). A typical error is to mix them up: the gcd is always at most both numbers; the lcm is at least both.
Think about it
Why is \(\gcd(a,b)=\gcd(a-b,\,b)\)?
Every common divisor of \(a\) and \(b\) divides \(a-b\); and every common divisor of \(a-b\) and \(b\) divides \((a-b)+b=a\). Both pairs have the same common divisors.
If \(\gcd(a,b)=6\) and \(\operatorname{lcm}(a,b)=60\), what is \(|ab|\)?
\(|ab|=\gcd\cdot\operatorname{lcm}=6\cdot60=360\).
Exercises 10
- Compute \(\gcd(12,18)\).
- Compute \(\gcd(35,64)\).
- Compute \(\gcd(0,9)\).
- Compute \(\gcd(48,180)\).
- Compute \(\gcd(84,126)\).
- Compute \(\gcd(1023,63)\), that is, \(\gcd(2^{10}-1,\,2^{6}-1)\).
- For which value of \(b\) does \(\gcd(20,b)=4\) hold?
- If \(d=\gcd(a,b)\) with \(a,b\) nonzero, what is \(\gcd(a/d,\,b/d)\)?
- How many integers \(n\) with \(1\le n\le100\) satisfy \(\gcd(n,100)=1\)?
- If \(\gcd(a,b)=1\), what values can \(\gcd(a+b,\,a-b)\) take for \(a\ne b\)?
References
- Kenneth H. Rosen, Discrete Mathematics and Its Applications, 8th edition, McGraw-Hill, 2019. §4.3
- Ralph P. Grimaldi, Discrete and Combinatorial Mathematics: An Applied Introduction, 5th edition, Pearson, 2003. §4.4
- Susanna S. Epp, Discrete Mathematics with Applications, 5th edition, Cengage, 2019. §4.8