Home page for accesible maths 4 Number theory

Style control - access keys in brackets

Font (2 3) - + Letter spacing (4 5) - + Word spacing (6 7) - + Line spacing (8 9) - +

4.2 Highest common factors and linear combinations

The first definition in this section concerns numbers which divide two given numbers.

Definition 4.2.1

Let a,b,ca,b,c\in\mathbb{Z}. We say that cc is a common factor (or a common divisor) of aa and bb if cc divides both aa and bb.

In other words, the set of common factors of aa and bb is the intersection of the sets of factors of aa and bb.

Example 4.2.2

The sets of factors of 1818 and 3030 are

{±1,±2,±3,±6,±9,±18}and{±1,±2,±3,±5,±6,±10,±15,±30};\{\pm 1,\pm 2,\pm 3,\pm 6,\pm 9,\pm 18\}\ \hbox{and}\ \{\pm 1,\pm 2,\pm 3,\pm 5% ,\pm 6,\pm 10,\pm 15,\pm 30\};

thus the set of common factors of 1818 and 3030 is {±1,±2,±3,±6}.\{\pm 1,\pm 2,\pm 3,\pm 6\}.

If aa and bb are not both zero, the set of common factors of aa and bb is clearly non-empty (as it contains 11) and bounded above (by |a||a| if a0a\neq 0, and by |b||b| otherwise), so it has a largest element. We may therefore make the following definition.

Definition 4.2.3

Given a,ba,b\in\mathbb{Z}, not both zero, the largest element of the set of common factors of aa and bb is called their highest common factor (or greatest common divisor), abbreviated hcf; we denote it by hcf(a,b)\mathrm{hcf}(a,b).

Example 4.2.4

From the set of common factors of 1818 and 3030 above, we have

hcf(18,30)=6.\mathrm{hcf}(18,30)=6.
Remark 4.2.5

There are several things to note about this definition:

  1. (i)

    hcf(0,0)\mathrm{hcf}(0,0) is not defined, since we stipulate that aa and bb are not both zero;

  2. (ii)

    hcf(a,b)=hcf(-a,b)\mathrm{hcf}(a,b)=\mathrm{hcf}(-a,b), because aa and -a-a have the same factors (see Remark 4.1.3(i));

  3. (iii)

    hcf(a,b)=hcf(b,a)\mathrm{hcf}(a,b)=\mathrm{hcf}(b,a);

  4. (iv)

    if b|ab|a then hcf(a,b)=|b|\mathrm{hcf}(a,b)=|b|.

Definition 4.2.6

If hcf(a,b)=1\mathrm{hcf}(a,b)=1, then we say that aa and bb are coprime.

Example 4.2.7

The set of factors of 3535 is {±1,±5,±7,±35}\{\pm 1,\pm 5,\pm 7,\pm 35\}. From above we see that the only common factors of 1818 and 3535 are ±1\pm 1; thus hcf(18,35)=1\mathrm{hcf}(18,35)=1, and 1818 and 3535 are coprime.

Lemma 4.2.8

Let a,b{0}a,b\in\mathbb{Z}\setminus\{0\}, and suppose that dd\in\mathbb{N} is a common factor of aa and bb such that every other common factor of aa and bb is a factor of dd. Then dd is the highest common factor of aa and bb.

Example 4.2.9

We saw in Example 4.2.2 that 66 is a common factor of 1818 and 3030, and each of their common factors ±1,±2,±3,±6\pm 1,\pm 2,\pm 3,\pm 6 divides 66. Hence 66 is the highest common factor of 1818 and 3030 (as we have already observed in Example 4.2.4).

Proof. By the assumptions, dd is a common factor of aa and bb, and for any other common factor cc of aa and bb, we have c|dc|d, so that c|d|=dc\leqslant|d|=d. Hence d=hcf(a,b)d=\mathrm{hcf}(a,b). \Box

We next give an important definition.

Definition 4.2.10

An (integral) linear combination of two integers aa and bb is an integer cc which can be written in the form c=ra+sbc=ra+sb for some r,sr,s\in\mathbb{Z}.

Example 4.2.11

The number 114114 is an integral linear combination of 1818 and 3030 because

114=318+230.114=3\cdot 18+2\cdot 30.

Note that there is no uniqueness about the coefficients rr and ss in this definition; it is quite possible for different choices of rr and ss to give the same integer c=ra+sbc=ra+sb. Indeed,

c=ra+sb=ra+ba+sb-ab=(r+b)a+(s-a)b,c=ra+sb=ra+ba+sb-ab=(r+b)a+(s-a)b,

so setting t=r+bt=r+b and u=s-au=s-a, we also have c=ta+ubc=ta+ub.

Example 4.2.12

We have 114=318+230114=3\cdot 18+2\cdot 30, but we can also write

114=(3+30)18+(2-18)30=3318+(-16)30.114=(3+30)18+(2-18)30=33\cdot 18+(-16)\cdot 30.

It is easy to see how divisibility relates to integral linear combinations.

Lemma 4.2.13

Let a,b,ca,b,c\in\mathbb{Z}, and suppose that cc is a common factor of aa and bb. Then cc is a factor of every integral linear combination of aa and bb.

Example 4.2.14

We have 3|183|18 and 3|303|30; so by the previous example we should have 3|1143|114 (which is true as 114=383114=38\cdot 3).

Proof. Suppose that a=pca=pc and b=qcb=qc for some p,qp,q\in\mathbb{Z}, and let nn\in\mathbb{Z} be an integral linear combination of aa and bb, so that n=ra+sbn=ra+sb for some r,sr,s\in\mathbb{Z}. Then we have

n=ra+sb=r(pc)+s(qc)=(rp+sq)c,n=ra+sb=r(pc)+s(qc)=(rp+sq)c,

and the result follows. \Box

Corollary 4.2.15

Let a,b{0}a,b\in\mathbb{Z}\setminus\{0\}, and suppose that dd\in\mathbb{N} is a common factor of aa and bb which is also an integral linear combination of aa and bb. Then d=hcf(a,b)d=\mathrm{hcf}(a,b).

Example 4.2.16

Since 5|255|25 and 5|355|35, and 325-235=53\cdot 25-2\cdot 35=5, we must have hcf(25,35)=5\mathrm{hcf}(25,35)=5 (which is clear from the set of factors of 3535 already given, as 7| 257\!\!\!\!\;\not\!\!\!\;|\!\;25 and 35| 2535\!\!\!\!\;\not\!\!\!\;|\!\;25).

Proof. Since dd is an integral linear combination of aa and bb, Lemma 4.2.13 implies that every common factor of aa and bb is a factor of dd. Hence d=hcf(a,b)d=\mathrm{hcf}(a,b) by Lemma 4.2.8. \Box

Our next result, called Bézout’s Theorem, will have a number of important consequences. In its proof we shall make use of the elementary fact that any non-empty set of natural numbers contains a smallest element. (This is obvious; we may simply count upwards from 11 until an element of the set is reached.)

Theorem 4.2.17

Let a,b{0}a,b\in\mathbb{Z}\setminus\{0\}. Then hcf(a,b)\mathrm{hcf}(a,b) is the smallest natural number which is an integral linear combination of aa and bb.

Example 4.2.18

We have hcf(18,30)=6\mathrm{hcf}(18,30)=6, and we may write 6=218+(-1)306=2\cdot 18+(-1)\cdot 30. The numbers {1,2,3,4,5}\{1,2,3,4,5\} cannot be written as integral linear combinations of 1818 and 3030.

Proof. Let SS be the set of natural numbers which are integral linear combinations of aa and bb; that is,

S={n:n=ra+sbfor somer,s}.S=\{n\in\mathbb{N}:n=ra+sb\ \text{for some}\ r,s\in\mathbb{Z}\}.

We see that SS is non-empty because it contains |a|=(±1)a+0b|a|=(\pm 1)\cdot a+0\cdot b, so it has a smallest element dd. Thus we have d=ra+sbd=ra+sb for some r,sr,s\in\mathbb{Z}. We shall prove that d=hcf(a,b)d=\mathrm{hcf}(a,b), which will give the result.

To see that d|ad|a, we use Theorem 4.1.8 to write a=qd+ta=qd+t with q,tq,t\in\mathbb{Z} and 0t<d0\leqslant t<d. Then

t=a-qd=a-q(ra+sb)=a-qra-qsb=(1-qr)a+(-qs)b,t=a-qd=a-q(ra+sb)=a-qra-qsb=(1-qr)a+(-qs)b,

so if t>0t>0 we would have tSt\in S, contrary to the minimality of dd. Hence we must have t=0t=0, and therefore a=qda=qd, i.e., d|ad|a.

A similar argument shows that d|bd|b, and so dd is a common factor of aa and bb.

We already know that dd is an integral linear combination of aa and bb, and hence Corollary 4.2.15 shows that d=hcf(a,b)d=\mathrm{hcf}(a,b). \Box

Corollary 4.2.19

Let a,b{0}a,b\in\mathbb{Z}\setminus\{0\}. Then aa and bb are coprime if and only if there exist r,sr,s\in\mathbb{Z} such that ra+sb=1ra+sb=1.

Example 4.2.20

As 1=218+(-1)351=2\cdot 18+(-1)\cdot 35, the numbers 1818 and 3535 must be coprime (as we have seen).

Proof. ‘‘\Rightarrow’’. Suppose that hcf(a,b)=1\mathrm{hcf}(a,b)=1. Then 11 is an integral linear combination of aa and bb by Theorem 4.2.17.

‘‘\Leftarrow’’. Suppose that 11 is an integral linear combination of aa and bb. Since no natural number is smaller than 11, Theorem 4.2.17 implies that hcf(a,b)=1\mathrm{hcf}(a,b)=1. \Box