Greatest Common Divisor

Overview

Let a and b be two nonzero integers. Then the greatest common divisor (GCD) of a and b, denoted gcd(a,b), is the greatest positive integer d such that d is a divisor of both a and b. If both a and b are zero, the GCD is considered either undefined or 0.

Let a and b be two integers. Then the least common multiple (LCM) of a and b, denoted lcm(a,b), is the smallest positive integer d such that a and b are both divisors of d. If either a or b is zero, the LCM is sometimes considered either undefined or 0.

Definitions

Group Theory

In group theory, the GCD of a,bZ+ is defined to be the positive generator of group {ma+nbm,nZ} under addition.

The LCM is defined to be the positive generator of aZbZ under addition.

Number Theory

In number theory, both GCD and LCM are defined by an appeal to the fundamental theorem of arithmetic. In particular, integers m and n have unique prime factorizations:

m=p1a1×p2a2××pkakn=p1b1×p2b2××pkbk

Then

lcm(m,n)=p1max(a1,b1)×p2max(a2,b2)××pkmax(ak,bk)gcd(m,n)=p1min(a1,b1)×p2min(a2,b2)××pkmin(ak,bk)

Order Theory

In order theory, the GCD is defined to be the greatest lower bound of the set of positive integers ordered by divisibility. That is, gcd(a,b)=inf{a,b} with respect to divisibility.

The LCM is similarly defined to be the least upper bound of the set of positive integers ordered by divisibility. That is, lcm(a,b)=sup{a,b} with respect to divisibility.

Monotonicity

Both GCD and LCM are monotonic under divisibility. That is,

Product Identity

We can relate lcm and gcd of two arguments like so:

lcm(a,b)=abgcd(a,b).

We can generalize to n argumets using PIE applied to maximums. This yields relationship:

lcm(a1,,an)=S{a1,,an}S oddgcd(S)S{a1,,an}S evengcd(S)

This immediately implies lcm(a1,,an)=a1an if and only if gcd(ai,aj)=1 for all 1i<jn.

Bézout's Lemma

For any pair of positive integers a and b, there exist integers m and n such that

gcd(a,b)=ma+nb.

Euclidean Algorithm

Let a,bZ+. By the division algorithm, there exist integers q and r such that a=bq+r where 0r<b. Then gcd(a,b)=gcd(b,r).

The Euclidean algorithm (also known as Euclid's algorithm) is a method for computing the GCD of two positive integers using the above identity. It works by repeatedly applying the division algorithm, stopping once the remainder is 0. For integers a,r0Z+, the process looks as follows:

a=r0q0+r1r0=r1q1+r2r1=r2q2+r3rn1=rnqn+0

This shows that gcd(a,r0)==gcd(rn1,rn)=gcd(rn,0)=rn.

Powered by Forestry.md