Lecture 11

In general, if we have positive integers aa and bb, with a>ba>b, we can start defining a sequence a0,a1,a_0, a_1, \ldots as follows:

This is a decreasing sequence, and eventually we will get ak=0a_k = 0 for some kk; we can’t divide by zero, so we end the sequence there.

We then have gcd(a,b)=gcd(a0,a1)=gcd(a1,a2)==gcd(ak1,0)=ak1.\gcd(a,b)=\gcd(a_0,a_1)=\gcd(a_1,a_2)=\cdots=\gcd(a_{k-1},0)=a_{k-1}.

Let’s write d=gcd(a,b)d=\gcd(a,b) for this.

Now, we have ak3=qk3ak2+ak1a_{k-3} = q_{k-3}a_{k-2} + a_{k-1}, so ak1=ak3qk3ak2a_{k-1} =a_{k-3} - q_{k-3}a_{k-2}, so we can write dd as a linear combination of ak3a_{k-3} and ak2a_{k-2}.

We have ak4=qk4ak3+ak2a_{k-4} = q_{k-4}a_{k-3} + a_{k-2}, so ak2=ak4qk4ak3a_{k-2} =a_{k-4} - q_{k-4}a_{k-3}, so substituting in we can write dd as a linear combination of ak4a_{k-4} and ak3a_{k-3}.

Proceeding in this way, we end up with dd as a linear combination of a0a_0 and a1a_1: in other words, of aa and bb.

We’ve proved the following:


[Bezout’s Lemma] Let aa and bb be two integers with gcd(a,b)=d\gcd(a,b)=d. Then there are integers mm and nn such that ma+nb=dma+nb=d.

In fact, slightly more is true:


Let aa and bb be two integers with gcd(a,b)=d\gcd(a,b)=d. Then, for an integer ee, we can write ee in the form e=ma+nbe=ma+nb if and only if ded\mid e.


The “if” part: We must prove that, if ded\mid e, then we can write ee as a linear combination of aa and bb.

However, since ded\mid e, we can write e=dke=dk for some kk. Also, by the above Proposition we can write d=ma+nbd=ma+nb for some mm and nn. But then e=dk=(mk)a+(nk)b,e = dk = (mk)a + (nk)b, as required.

The “only if” part: We must prove that if e=ma+nbe=ma+nb, then ded\mid e. But, since d=gcd(a,b)d=\gcd(a,b) we have dad\mid a and dbd\mid b, and hence also dmad\mid ma and dnbd\mid nb, and therefore dma+nbd\mid ma+nb as required.

The fundamental theorem of arithmetic

We’ll go on now and describe three uses of this result. Firstly, we return to the question of unique factorisation into primes. Of course we’ve proved that every positive integer can be written as a product of primes. The question is, can every positive integer be written as a product of primes in only one way?

Of course, we should be careful to say what we mean by “only one way”. We certainly do have: 420=2×2×3×5×7=5×2×3×7×2=7×5×3×2×2,and so on\begin{aligned} 420 &= 2 \times 2 \times 3 \times 5 \times 7\\ &= 5 \times 2 \times 3 \times 7 \times 2\\ &= 7 \times 5 \times 3 \times 2 \times 2,\quad\text{and so on\ldots}\end{aligned} Clearly, what we mean is that every positive integer can be written as a product of primes in only one way, where reordering doesn’t count as different. Or, more precisely, that any two ways of writing a positive integer as a product of primes differ only by reordering. Mathematicians say, “in only one way, up to reordering”.

So the question we ask ourselves is (for example) why we can’t have 487×205339=7×17×59×14243,487 \times 205339 = 7 \times 17 \times 59 \times 14243, (I promise you that all six of those numbers are prime).

One wants to say something like “as the right-hand side is clearly divisible by 77, the left-hand side must be divisible by 77 too, but there isn’t a 77 listed among the primes on the left”.

But if we have 7(487×205339)7\mid(487 \times 205339), why must we have either 74877\mid 487 or 72053397\mid 205339? It wouldn’t be true if 77 weren’t a prime. But this is true for primes!


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

This result is not only not obvious, we should expect it to be difficult. The definition of “pp being prime” talks about what things divide pp. But this result says something about what things pp divides, which is completely unrelated.


Suppose that pabp\mid ab, and consider gcd(p,a)\gcd(p,a). Since gcd(p,a)p\gcd(p,a)\mid p, we either have gcd(p,a)=1\gcd(p,a)=1 or gcd(p,a)=p\gcd(p,a)=p.

If gcd(p,a)=p\gcd(p,a)=p, then as gcd(p,a)a\gcd(p,a)\mid a, we have pap\mid a.

If gcd(p,a)=1\gcd(p,a)=1, however, then by Bezout’s Lemma, we know that there are integers mm and nn such that mp+na=1mp+na=1. Now suppose we multiply both sides by bb; we get mpb+nab=bmpb+nab=b.

Clearly pmpbp\mid mpb, and also we have pnabp\mid nab since we are supposing that pabp\mid ab. Hence pmpb+nabp\mid mpb+nab, so pbp\mid b, as needed.

The second part of this proof can in fact be used to show that, for any integers nn, aa and bb, that if nabn\mid ab and gcd(n,a)=1\gcd(n,a)=1, then nbn\mid b.

We can also boost it to a result about a product of lots of terms:


Let pp be a prime and let a1,,ana_1,\ldots,a_n be integers. Then if pa1anp\mid a_1\cdots a_n, then paip\mid a_i for some ii.

This is an easy induction argument using above.

Now, equipped with that tricky result, we’re ready to prove the main result of this section:


[Fundamental Theorem of Arithmetic] Any positive integer nn can be written as a product of primes in exactly one way, up to reordering.


We have shown that any positive integer can be written as a product of primes. We need to show that this expression is unique. We’ll prove it by contradiction.

Suppose not: there is a number nn with two genuinely different prime factorisations n=p1prn=p_1\cdots p_r and n=q1qsn=q_1\cdots q_s. We can suppose that the pp’s and the qq’s have nothing in common (if pi=qjp_i = q_j, then we can cancel them out and use p1pi1pi+1pr=q1qj1qj+1qsp_1\cdots p_{i-1}p_{i+1}\cdots p_r = q_1\cdots q_{j-1}q_{j+1}\cdots q_s, which is a smaller example).

Now, that means that p1p_1 is different to all of q1,q2,,qsq_1,q_2,\ldots,q_s.

We have p1np_1\mid n, since n=p1prn=p_1\cdots p_r. But then we also have p1q1qsp_1\mid q_1\cdots q_s. But by our previous result, this means that p1qjp_1\mid q_j for some jj. But, by the definition of qjq_j being a prime number, that means that p1=qjp_1=q_j, which we said didn’t happen: that gives us our contradiction.

Linear diophantine equations

A diophantine equation is an equation where we’re interested in solutions with the variables lying in N\mathbb{N} or Z\mathbb{Z}. They’re named after the ancient Greek mathematician Diophantus of Alexandria.

An example of a diophantine equation is the Fermat equation for exponent 7: x7+y7=z7.x^7 + y^7 = z^7.

If we were interested in solutions to this equation over R\mathbb{R}, the story would be really, really simple: we could take any xx and any yy we wanted and then just take z=x7+y77.z = \sqrt[7]{x^7 + y^7}. The Fermat equation becomes more interesting because of our inability to reliably take nnth roots in Z\mathbb{Z} or N\mathbb{N}: which xx and yy can we take for which this recipe works?

While they’re much easier, a similar thing is true of linear diophantine equations: equations of the form ax+by=c,ax + by = c, where aa, bb and cc are integer constants.

Consider, for example, the equation 39x+54y=12039x + 54y = 120.

This equation would be simple if we cared about real solutions: we could take any xx we like and then just take y=(12039x)/54y = (120-39x)/54. However, because we can’t do division reliably in Z\mathbb{Z}, this recipe is not very helpful: how do we know which xx will give us an integer yy?