2.5 Integers

In this section, we focus on integers and explore their properties. We end by proving the so-called Fundamental Theorem of Arithmetic, which states that any integer can be broken down into a product of primes in a unique way.

2.5.1 Divisors

Definition 2.25 (Divisor).

Let aa and dd be integers, with d0d\neq 0. We say that dd divides aa, and that dd is a divisor (or factor) of aa, if ad\frac{a}{d} is an integer. We also say that aa is divisible by dd.

We shall write dad\mid a to mean dd divides aa, and dad\nmid a to mean that dd does not divide aa.

For example:

  • 33 divides 1212, since 123=4\frac{12}{3}=4 is an integers, and so we write 3123\mid 12;

  • 312-3\mid 12 since 123=4\frac{12}{-3}=-4 is an integer;

  • 12312\nmid 3 since 312=14\frac{3}{12}=\frac{1}{4} is not an integer;

  • 5125\nmid 12 since 125\frac{12}{5} is not an integer;

  • 050\mid 5 is meaningless since we must have d0d\neq 0 in the definition.

  • for any integer kk, we have 1k1\mid k and 1k-1\mid k (since k1\frac{k}{1} and k1\frac{k}{-1} are integers); and

  • for any nonzero integer kk, we have kkk\mid k and kk-k\mid k.

You may be familiar with the term factor from your previous studies; this means the same as divisor.

Proposition 2.26.

Suppose that aa and dd are integers, with d0d\neq 0. The integer dd is a divisor of aa if and only if there exists an integer kk such that a=kda=kd.

Proof.

We shall prove both directions of the ‘if and only if’ statement at once.

By Definition 2.25, dad\mid a is equivalent to ad\frac{a}{d} being an integer. Let k=adk=\frac{a}{d} be that integer. The equation k=adk=\frac{a}{d} is equivalent to a=kda=kd.

Definition 2.27 (Common divisor).

Let aa and bb be integers. If dad\mid a and dbd\mid b then we say dd is a common divisor of aa and bb.

Note that, in this definition, there is an implicit assumption that d0d\neq 0 because stating dad\mid a only makes sense if dd is a nonzero integer by Definition 2.25.

Lemma 2.28 (Linear Combination Lemma).

Let aa and bb be integers with common divisor dd. Then, for any pair of integers mm and nn, the integer ma+nbma+nb is divisible by dd.

Note that the expression ma+nbma+nb above is called a linear combination of aa and bb, hence the name of the lemma.

Proof.

Suppose aa and bb are integers with common divisor dd, and let mm and nn be integers.

By Definition 2.25, ad\frac{a}{d} and bd\frac{b}{d} are both integers. The product of two integers is an integer, and so n×ad=nadn\times\frac{a}{d}=\frac{na}{d} and m×bd=bmdm\times\frac{b}{d}=\frac{bm}{d} are also integers. The sum of two integers is an integer, and so nad+mbd=na+mbd\frac{na}{d}+\frac{mb}{d}=\frac{na+mb}{d} is also an integer. Hence, by Definition 2.25, d(ma+nb)d\mid(ma+nb).

Exercise 2.29.

Write an alternative proof of Lemma 2.28 using the result from Proposition 2.26.

Solution (please try for yourself before looking)

We wish to prove that if aa and bb have common divisor dd then, for any integers mm and nn, we have dma+nbd\mid ma+nb.

Using Proposition 2.26, aa having divisor dd means that there exists an integer kk such that a=kda=kd. Similarly, bb having divisor dd means that there exists an integer ll such that b=ldb=ld. Then, for any integers mm and nn, we have

ma+nb=mkd+nld=(mk+nl)d.ma+nb=mkd+nld=(mk+nl)d.

Because mm, kk, nn and ll are integers, then so is (mk+nl)(mk+nl) and so Proposition 2.26 tells us that dma+nbd\mid ma+nb.

Exercise 2.30.

Use Lemma 2.28 to prove that the only integers which can divide a pair of consecutive integers are 11 and 1-1.

Solution (please try for yourself before looking)

Let nn be an integer and suppose dnd\mid n and d(n+1)d\mid(n+1). Applying Lemma 2.28 (with m=1m=-1 and n=1n=1) tells us that dd must divide 1×n+1×(n+1)=1-1\times n+1\times(n+1)=1. But the only divisors of 11 are 11 and 1-1. Thus d=1d=1 or d=1d=-1.

Definition 2.31 (Greatest common divisor, gcd\gcd).

Let aa and bb be integers, not both zero. The greatest common divisor of aa and bb, denoted by gcd(a,b)\gcd(a,b), is the largest common divisor of aa and bb.

You should be wary of definitions like this that depend on the ‘existence and uniqueness’ of an object; notice that this definition only makes sense if aa and bb actually have a common divisor at all, and that they have a unique largest one.

Exercise 2.32.

Let’s explore Definition 2.31.

  1. (a)

    How do you know that aa and bb really do have a common divisor?

  2. (b)

    How do you know that they have a greatest common divisor?

  3. (c)

    Why is it necessary to assume that aa and bb should be ‘not both zero’?

Solution (please try for yourself before looking)
  1. (a)

    Every integer (including zero) has divisors 11 and 1-1, so any pair of integers has (at least) these in common.

  2. (b)

    Assuming a0a\neq 0, the largest divisor of aa is |a||a|. [Why is this the case? Why |a||a| rather than aa?] So the largest a common divisor of aa and bb could be is the smaller of |a||a| and |b||b|.

  3. (c)

    Suppose aa and bb were both zero. Then every nonzero integer dd is a common divisor of aa and bb, and so there is no largest common divisor.

2.5.2 Coprime integers

Definition 2.33 (Coprime).

Let aa and bb be integers. We say that aa and bb are coprime if gcd(a,b)=1\gcd(a,b)=1.

For example:

  • 33 and 99 are not coprime because gcd(3,9)=3\gcd(3,9)=3;

  • 88 and 1515 are coprime because gcd(8,15)=1\gcd(8,15)=1. [Try listing the divisors of 88 and 1515.]

Exercise 2.34.

Which integers are coprime with 0?

Solution (please try for yourself before looking)

Because gcd(0,0)\gcd(0,0) is not defined, it only makes sense to consider n0n\neq 0.

Every nonzero integer is a divisor of 0 and so gcd(n,0)=|n|\gcd(n,0)=|n|. Therefore only 11 and 1-1 are coprime with 0.

Lemma 2.35.

Let aa and bb be integers. If there exist integers mm and nn such that ma+nb=1ma+nb=1 then aa and bb are coprime.

Proof.

Let aa and bb be integers. Suppose there exist integers mm and nn such that ma+nb=1ma+nb=1. Let dd be a positive common divisor of aa and bb, so that ad\frac{a}{d} and bd\frac{b}{d} are integers. The equation

mad+nbd=1dm\tfrac{a}{d}+n\tfrac{b}{d}=\tfrac{1}{d}

also holds.

Since mm, ad\frac{a}{d}, nn and bd\frac{b}{d} are integers, so is the entire left-hand side of the equation. Thus 1d\tfrac{1}{d} must be an integer too, hence d=1d=1. Therefore 11 is the only positive common divisor of aa and bb.

Lemma 2.36 (Bézout’s Lemma (Special Case)).

Let aa and bb be coprime integers. Then there exist integers mm and nn such that ma+nb=1ma+nb=1.

This is a special case of a result known as Bézout’s lemma.

Proof.

Our strategy is to show that every possible linear combination na+mbna+mb is a multiple of some constant, then use the fact that aa and bb are coprime to deduce that this constant must be 1.

Fix integers aa and bb. For each mm and nn, the expression na+mbna+mb is some integer. Because each possible value of na+mbna+mb is an integer, there must be a smallest positive one – call it ss. In other words, there exists integers m0m_{0} and n0n_{0} such that

m0a+n0b=s.m_{0}a+n_{0}b=s. (2.2)

First we prove that every linear combination ma+nbma+nb must be divisible by ss. For a contradiction, assume that some ma+nbma+nb is not divisible by ss. Then dividing ma+nbma+nb by ss must leave some nonzero remainder. Hence we can write

ma+nb=cs+rma+nb=cs+r (2.3)

for some integers cc and rr with 0<r<s0<r<s. [Convince yourself of this.] Then

r\displaystyle r =ma+nbcs\displaystyle=ma+nb-cs (rearranging equation 2.3)
=ma+nbc(m0a+n0b)\displaystyle=ma+nb-c(m_{0}a+n_{0}b) (by equation 2.2)
=(mcm0)a+(ncn0)b\displaystyle=(m-cm_{0})a+(n-cn_{0})b (rearranging).

Therefore rr is a linear combination of aa and bb that is positive and strictly smaller than ss. This is a contradiction, since ss is the smallest of these. So no such rr can exist in equation 2.3, thus ma+nbma+nb must divisible by ss.

Second, we know two possible linear combinations:

  • putting m=1m=1 and n=0n=0 gives us the linear combination 1.a+0.b=a1.a+0.b=a;

  • putting m=0m=0 and n=1n=1 gives us the linear combination 0.a+1.b=b0.a+1.b=b.

Above, we proved that any linear combination must be a multiple of the smallest one ss. In particular, aa and bb must be multiples of ss; that is, ss is a common divisor of aa and bb. But aa and bb are coprime, so ss must be 11. Then equation 2.2 gives the result.

Exercise 2.37.

Lemma 2.35 and Lemma 2.35 are converses. Summarise these two results in one ‘if and only if’ statement.

Solution (please try for yourself before looking)

Let aa and bb be integers. There exist integers mm and nn such that am+bn=1am+bn=1 if and only if aa and bb are coprime.

2.5.3 Prime numbers

Definition 2.38 (Prime).

An integer p>1p>1 is prime if its only positive divisors are 11 and pp.

For example:

  • 11 is not prime because primes have to be greater than 11;

  • 22 is prime because its only positive divisors are 11 and 22;

  • 33 is prime because its only positive divisors are 11 and 33;

  • 44 is not prime because 242\mid 4.

Observe that once we know an integer pp is prime then, for every positive integer n>1n>1, we know npnp is not prime. [Why?] This observation gives a way of listing prime numbers known as the Sieve of Eratosthenes.

Exercise 2.39.

Prove that a prime cannot divide two consecutive integers.

Solution (please try for yourself before looking)

By definition, a prime number must be an integer greater than 11. By 2.30, the only integers that divide a pair of consecutive integers are 11 and 1-1.

Exercise 2.40.

Suppose pp is prime and aa is an integer. What could gcd(a,p)\gcd(a,p) be? Which integers aa are such that gcd(a,p)=p\gcd(a,p)=p?

Solution (please try for yourself before looking)

The divisors of a prime pp are precisely 1,1,p,p1,-1,p,-p, so the only possible values of gcd(a,p)\gcd(a,p) are 11 and pp. Think about different values of aa and list their divisors.

  • Set a=1a=1. The divisors of 11 are precisely 1,11,-1, so gcd(1,p)=1\gcd(1,p)=1.

  • Set a=1a=-1. The divisors of 1-1 are precisely 1,11,-1, so gcd(1,p)=1\gcd(1,p)=1.

  • Set a=pa=p. The divisors of pp are precisely 1,1,p,p1,-1,p,-p, so gcd(p,p)=p\gcd(p,p)=p.

  • Set a=0a=0. Every nonzero integer is a divisor of 0, so gcd(0,p)=p\gcd(0,p)=p (the greatest divisor of pp).

  • If pp appears in the list of divisors of aa then gcd(a,p)=p\gcd(a,p)=p.

  • If pp does not appear in the list of divisors of aa then gcd(a,p)=1\gcd(a,p)=1.

In summary,

gcd(a,p)={pif pa1otherwise.\gcd(a,p)=\begin{cases}p&\text{if $p\mid a$}\\ 1&\text{otherwise.}\end{cases}
Lemma 2.41 (Euclid’s lemma).

Let aa and bb be integers, and pp be prime. If pabp\mid ab then pap\mid a or pbp\mid b.

Proof.

Suppose pabp\mid ab and pap\nmid a; we shall show that pp must divide bb. Since pp is prime and pap\nmid a it follows that gcd(a,p)=1\gcd(a,p)=1. Thus, by Lemma 2.36, there are integers mm and nn such that

ma+np=1.ma+np=1.

Multiplying both sides by bb gives

mab+npb=b.mab+npb=b.

But pabp\mid ab and pnpbp\mid npb, so pp divides the left-hand side of the equation. Therefore it must divide bb, the right-hand side, by the Linear Combination Lemma (Lemma 2.28).

The same argument can be applied to prove that if pabp\mid ab and pbp\nmid b then pap\mid a. Therefore the proof is complete.

Lemma 2.42.

Let a1,a2,,aka_{1},a_{2},\ldots,a_{k} be integers, and pp be prime. If pa1a2akp\mid a_{1}a_{2}\cdots a_{k} then pp divides at least one of a1,a2,,aka_{1},a_{2},\ldots,a_{k}.

Proof.

For a contradiction, suppose a1,a2,,aka_{1},a_{2},\ldots,a_{k} is the shortest list of integers such that pa1a2akp\mid a_{1}a_{2}\cdots a_{k} but pp does not divide any of a1,a2,aka_{1},a_{2},\ldots a_{k}. We know from Lemma 2.41 that k>2k>2. [Think about where we use this in the proof.]

Now

pa1(a2ak)p\mid a_{1}(a_{2}\cdots a_{k})

and so Lemma 2.41 tells us that pa1p\mid a_{1} or p(a2ak)p\mid(a_{2}\cdots a_{k}). By assumption, pa1p\nmid a_{1} and so p(a2ak)p\mid(a_{2}\cdots a_{k}). But a2,a3,,aka_{2},a_{3},\ldots,a_{k} is a shorter list than a1,a2,,aka_{1},a_{2},\ldots,a_{k} and so it must be the case that pp divides one of a2,a3,,aka_{2},a_{3},\ldots,a_{k}. This contradicts the existence of such a list a1,a2,,aka_{1},a_{2},\ldots,a_{k}.

Note that there is an alternative proof using ‘strong induction’, a technique we shall discuss in the next chapter.

2.5.4 The Fundamental Theorem of Arithmetic

We shall now prove an important result about the role of primes. The Fundamental Theorem of Arithmetic states that any integer can be written as a product of primes in a unique way.

Theorem 2.43 (The Fundamental Theorem of Arithmetic).

Let n>1n>1 be an integer. Then there is a list of positive primes p1,p2,,pkp_{1},p_{2},\ldots,p_{k} such that

n=p1p2pk.n=p_{1}p_{2}\cdots p_{k}. (2.4)

The primes p1,p2,,pkp_{1},p_{2},\ldots,p_{k} are unique up to reordering.

First let’s interrogate this theorem to make sure we understand the claim. Here are some examples of writing integers as a product of primes.

  • 22 is prime and we can write 2=22=2. In equation 2.4, n=2n=2 and p1=2p_{1}=2.

  • 33 is prime; 3=33=3. In equation 2.4, n=3n=3 and p1=3p_{1}=3.

  • 4=2×24=2\times 2; n=4n=4, p1=2p_{1}=2, p2=2p_{2}=2.

  • 6=2×36=2\times 3; n=6n=6, p1=2p_{1}=2, p2=3p_{2}=3.

  • 8=2×2×28=2\times 2\times 2; n=8n=8, p1=2p_{1}=2, p2=2p_{2}=2, p3=2p_{3}=2.

  • 10=2×510=2\times 5; n=10n=10, p1=2p_{1}=2, p2=5p_{2}=5.

The claim that primes p1,p2,,pkp_{1},p_{2},\ldots,p_{k} are ‘unique up to reordering’ means, for example, if n=6n=6 then we could have either (i) p1=2p_{1}=2 and p2=3p_{2}=3 or, (ii) p1=3p_{1}=3 and p2=2p_{2}=2. However, there is no other way to write 66 as a product of primes. The collection of primes, unordered, is unique.

Note that Definition 2.38 requires prime numbers to be greater than 11. Can you see why considering 11 to be prime would complicate the statement of this theorem?

Proof.

Our strategy is to prove that nn can be written as a product of primes, and then prove that this factorisation is unique.

First, we prove that nn can be written as a product of primes. For a contradiction, assume that n>1n>1 cannot be written as a product of primes and is the smallest integer with this property. Because such an nn cannot be prime itself [think about why], it must have a positive non-prime divisor dd strictly greater than 11 and less than nn. [Think about why – try listing divisors of nn.] Thus n=dkn=dk for some positive integers dd and kk, both strictly smaller than nn. Because dd and kk are smaller than nn, and because we assumed nn was the smallest integer that could not be written as a product of primes, it must be possible to write dd and kk as a product of primes. But then nn is the product of dd and kk, both of which are a product of primes. Hence nn must also be a product of primes. Contradiction; no such nn can exist.

Now we prove that p1,p2,pkp_{1},p_{2},\ldots p_{k} are unique up to reordering. For a contradiction, assume that n>1n>1 is the smallest integer with two different prime factorisations. That is, there is a different list of primes q1,q2,qlq_{1},q_{2},\ldots q_{l} such that

n=p1p2pk=q1q2ql.n=p_{1}p_{2}\cdots p_{k}=q_{1}q_{2}\cdots q_{l}.

Now p1p_{1} divides p1p2pkp_{1}p_{2}\cdots p_{k}, so it must also divide q1q2qlq_{1}q_{2}\cdots q_{l}. By Lemma 2.42, this means p1p_{1} divides some qjq_{j}. But qjq_{j} is prime and so p1=qjp_{1}=q_{j}. In other words, the same prime appears on both lists. Delete this prime from each list to get two new lists:

p2,p3,,pk and q1,q2,qj1,qj+1,ql.p_{2},p_{3},\ldots,p_{k}\quad\text{ and }\quad q_{1},q_{2},\ldots q_{j-1},q_{j% +1},\ldots q_{l}.

[Don’t be confused by the notation in the second list – this is just q1,q2,,qlq_{1},q_{2},\ldots,q_{l} with qjq_{j} missing.] These lists must be different because we removed the same prime from each. But then

np1=p2p3pk=q1q2qj1qj+1ql\frac{n}{p_{1}}=p_{2}p_{3}\cdots p_{k}=q_{1}q_{2}\cdots q_{j-1}q_{j+1}\cdots q% _{l}

is a positive integer smaller than nn that can be written as a product of primes in two different ways. Contradiction, since we assumed nn was the smallest such integer.

The Fundamental Theorem of Arithmetic has many important consequences, some of which you have known for a long time. For example, in our proof that 2\sqrt{2} is irrational (Theorem 2.22), we assumed that a fraction of integers a/ba/b could be written in simplest terms. The fact that this is possible is really a consequence of the Fundamental Theorem of Arithmetic: we can express aa and bb as products of primes and then cancel factors until the fraction is as simple as possible.

2.5.5 Euclid’s theorem that there are infinitely many primes

We end this section on integers by presenting a classical result that there are infinitely many prime numbers.

Theorem 2.44 (Euclid’s theorem).

There are infinitely many primes.

Proof.

The strategy here is to start with a finite list of primes and then prove that there must be another one not on the list.

Let p1,p2,,pnp_{1},p_{2},\ldots,p_{n} be a list of nn primes. Define qq to be the integer p1p2pn+1p_{1}p_{2}\cdots p_{n}+1. Since qq is an integer greater than 11, it is either prime or not. Consider these cases separately.

  1. (i)

    Suppose qq is prime. Then it cannot be one of p1,p2,,pnp_{1},p_{2},\ldots,p_{n} because it is greater than each pip_{i}. [Why?] Thus qq is a prime not on the list of nn primes.

  2. (ii)

    Suppose qq is not prime. The integers p1p2pnp_{1}p_{2}\cdots p_{n} and qq are consecutive, and each pip_{i} in the list divides p1p2pnp_{1}p_{2}\cdots p_{n}, so none of the pip_{i} can divide qq by 2.30. But, by the Fundamental Theorem of Arithmetic, qq must have a prime divisor and so there must be a prime number that is not on the list.

Note that you will often see this proof start with the assumption that p1,p2,,pnp_{1},p_{2},\ldots,p_{n} is a list of all primes. As you can see from the proof above, it is not necessary to do this.

Note also that if p1,p2,,pnp_{1},p_{2},\ldots,p_{n} is a list of primes (including perhaps all of them) then the proof does not assert that the number

P:=p1p2pn+1P:=p_{1}p_{2}\cdots p_{n}+1

is itself prime. The proof shows (i) it is not equal to any pkp_{k} and (ii) is not divisible by any pkp_{k}. In fact, PP need not be prime! For example

2×3×5×7×11×13+1=30031=59×509.2\times 3\times 5\times 7\times 11\times 13+1=30031=59\times 509.