64. Properties of the GCD
If $m > 1$ and $n > 1$, and you know the prime factorizations of both of them, the GCD and LCM can be calculated using the following theorem, in which $\mathrm{e}_{p}(m)$ denotes the exponent of $p$ in $m$ (Definition 62.3), $\min(r,s)$ denotes the smaller of $r$ and $s$ and $\max(r,s)$ the larger.
64.1 Theorem
Let $p$ be a prime and $m$ and $n$ positive integers. Then
$$\mathrm{e}_{p}(\operatorname{GCD}(m,n)) = \min(\mathrm{e}_{p}(m),\mathrm{e}_{p}(n))$$
and
$$\mathrm{e}_{p}(\operatorname{LCM}(m,n)) = \max(\mathrm{e}_{p}(m),\mathrm{e}_{p}(n))$$
64.1.1 Example $60 = 2^{2} \times 3\times 5$ and $72 = 2^{3} \times 3^{2}$. Their GCD is $12 = 2^{2} \times 3$, in which 2 occurs $\min(2,3)$ times, 3 occurs $\min(1,2)$ times, and 5 occurs $\min(1,0)$ times. Their LCM is $360 = 2^{3} \times 3^{2} \times 5$.
64.2 Corollary
Let $m$ and $n$ be nonnegative integers. $\operatorname{GCD}(m,n)$ is the unique nonnegative integer with these properties:
a) $\operatorname{GCD}(m,n)$ divides both $m$ and $n$.
b) Any integer $e$ which divides both $m$ and $n$ must divide $\operatorname{GCD}(m,n)$.
64.2.1 Remark The property of GCD given in this corollary is often taken as the definition of GCD. Note that no special consideration has to be given to the case $m = n = 0$.
64.2.2 Exercise Prove Corollary 64.2. (This corollary can be proved without using the Fundamental Theorem of Arithmetic. See Exercise 88.3.8, page 130.) (Answer on page 246.)
64.2.3 Exercise Use Theorems 62.4 and 64.1 to prove these facts about the GCD and the LCM:
a) $\operatorname{GCD}(m,n)\operatorname{LCM}(m,n) = mn$ for any positive integers $m$ and $n$.
b) If $m$ and $n$ are relatively prime, then $\operatorname{LCM}(m,n) = mn$.
64.2.4 Exercise Prove that if $d = \operatorname{GCD}(m,n)$, then $m/d$ and $n/d$ are relatively prime. (Answer on page 246.)
64.2.5 Exercise Prove that every rational number has a representation in lowest terms.
64.2.6 Exercise Prove that GCD is commutative: for all integers $m$ and $n$, $\operatorname{GCD}(m,n) = \operatorname{GCD}(n,m)$.
64.2.7 Exercise Prove that GCD is associative:
$$\operatorname{GCD}(\operatorname{GCD}(k,m),n) = \operatorname{GCD}(k,\operatorname{GCD}(m,n))$$
Hint: Use Theorem 64.1 and the fact that the smallest of the numbers $x$, $y$ and $z$ is
$$\min(x,\min(y,z)) = \min(\min(x,y),z) = \min(x,y,z)$$
64.2.8 Exercise (Mathematica)
a) Use Mathematica to determine which ordered pairs $\langle a,b\rangle$ of integers, with $a\in \{ 1,\ldots , 10\}$, $b \in \{ 1,\ldots , 10\}$, have the property that the sequence $a + b, 2a + b,\ldots , 10a + b$ contains a prime.
b) Let (C) be the statement:
There is an integer $k > 0$ for which $ak + b$ is prime.
(The integer $k$ does not have to be less than or equal to 10.) Based on the results, formulate a predicate $P(a,b)$ such that the condition (C) implies $P(a,b)$. The predicate $P$ should not mention $k$.
c) Prove that (C) implies $P(a,b)$.
Note: Define a function by typing t[a_,b_] := Table[a k + b,{k,1,10}] (notice the spacing and the underlines). Then if you type, for example, t[3,5], you will get {8,11,14,17,20,23,26,29,32,35}. If L is a list, Select[L,PrimeQ] produces a list of primes occurring in L.
64.3 Extensions of the definition of GCD
GCD is often defined for all integers, so that $\operatorname{GCD}(m,n)$ is $\operatorname{GCD}(|m|,|n|)$. For example, $\operatorname{GCD}(-6,4) = \operatorname{GCD}(6,-4) = \operatorname{GCD}(-6,-4) = 2$. With this extended definition, GCD is an associative and commutative binary operation on $\mathrm{Z}$ (Section 143.2.1). Associativity means it is unambiguous to talk about the GCD of more than two integers. In fact, we can define that directly:
64.4 Definition: generalized GCD
Let $n_{1}, n_{2},\ldots ,n_{k}$ be integers. Then $\operatorname{GCD}(n_{1},\ldots ,n_{k})$ is the largest integer that divides all the numbers $|n_{1}|,|n_{2}|,\ldots ,|n_{k}|$.
64.4.1 Example $\operatorname{GCD}(4,6,-8,12) = 2$.
64.4.2 Remarks
a) Similar remarks can be made about the LCM.
b) These functions are implemented in Mathematica using the same names. For example, GCD[4,6,-8,12] returns 2.
Pages 90–91 of the book (PDF).