Number Theory I

Greg Gamble

May 24, 1997

Number Theory is mainly concerned with properties of the natural numbers (or positive integers):

N = Z + = {1,2,3,...}

and more generally with the integers:

Z = {...,-3,-2,-1,0,1,2,3,...}.

Divisibility

If a,b in Z we say: a divides b, and write: a divides b, if b = aq for some integer q. Otherwise, a does not divide b and we write: a ndivides b. For example,

7 divides 35,  -3 divides 21,  4 divides 0   and (a + 1) divides a2 - 1 for any integer a

but

7 ndivides 33,  -3 ndivides 22,  0 ndivides 4.

If a divides b then we also say: a is a divisor (or factor) of b, or that: b is a multiple of a. For example, if b = 12 then the divisors (factors) of b are

a in {±1, ±2, ±3, ±4, ±6, ±12}.

Aside: Don´t confuse the divides symbol: divides (which is a vertical stroke with a little space around it) with the slash symbol: / (which separates the numerator and denominator of a fraction). Also, note that despite the symmetry of the symbol: divides the symbol cannot be used in reverse, i.e. a divides b and b divides a mean different things (in fact, if they are both true then a = ± b).

Property 1. If a divides b and a divides c then a divides bx + cy for any integers x,y.

Proof: Suppose a divides b and a divides c. Then b = aq and c = ar for some integers q,r. So, for any integers x,y,

bx + cy = a(qx + ry)

and qx + ry is an integer, and hence a divides bx + cy.

box

Summary of divisibility terms

Summarising the above statements, all the following say the same thing about integers a,b where a ne 0.

Prime numbers

A prime number is a natural number larger than 1 that is only divisible by itself and 1.
A natural number that is neither 1 nor prime is called composite.
Aside: Notice that 1 is neither prime nor composite. In fact, 1 is called a unit (the technical term for a number that divides all integers).
What makes primes so interesting is that every natural number (other than 1) can be expressed in just one way (except that we may be able to arrange the factors in many ways) as the product of prime divisors, e.g.

74844 = 22.35.7.11.

Such a factorisation is called a prime decomposition.

Aside: If we were to include 1 as a prime then 74844 = 15.22.35.7.11, say, would be ``another prime decomposition''. Excluding 1 as a prime ensures the uniqueness of prime decompositions.
The above fact is so important it is given a special name. Let´s give it its name and recap what it says:

Fundamental theorem of arithmetic. Any natural number n, other than 1, can be written uniquely as follows:

n = p1e1p2e2... pkek,

where k is a natural number, each pi is a prime number and 1 < p1 < p2 < ... < pk, and each ei is a natural number.

A fundamental property of primes is expressed in the following result:

Euclid's Lemma. If a prime p divides ab then p divides a or p divides b.

How can we decide whether a given, possibly quite large, natural number n is prime? Well ... if n is composite then n = ab for some natural numbers a,b such that neither a nor b is 1 or n; and either a = b = sqrt n or one of a or b is less than sqrt n. Thus, to show n is prime we need only show it has no prime divisors less than or equal to sqrt n.

Example 1. 97 is prime, since

Remark. The primes less than 100 are:

2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97.

This is easy to check, because at most we need only check divisibility by 2, 3, 5 and 7. Incidentally, there are 25 of them!

Greatest common divisor

The greatest common divisor (or highest common factor) of two integers a,b, denoted by gcd(a,b) or hcf(a,b) or simply (a,b), is the largest natural number that divides both a and b. (Here we must insist that a and b are not both zero.)
Aside: If (a,b) = 1 then a,b are said to be relatively prime or coprime.
You may be familiar with an algorithm for finding the gcd of two integers a,b which involves first finding the prime decompositions of a,b. While this procedure works well when a,b are small (particularly, if both a and b are smaller than 100, say), it is quite inefficient if a,b are large; since, in general, finding prime decompositions is difficult.
Aside: The difficulty of finding prime decompositions is exploited in many encryption algorithms.
Below, we will see a method for finding greatest common divisors that doesn´t require finding prime decompositions. The method requires application of the Division Algorithm (usually, several times) which we now describe.

Division Algorithm. For integers a,b with a ne 0 there exist integers q (the quotient) and r (the remainder) such that

b = aq + r and 0 le r < a.

Essentially q,r are the numbers that make the following division work:

q rem. r
               
)b

Let´s apply the Division Algorithm to a few examples:

ifa = 7 andb = 22 we write 22 = 7.3 + 1 (so q = 3 and r = 1);
ifa = 113andb = 355we write355 = 113.3 + 16 (so q = 3 and r = 16);
ifa = 8 andb = 72 we write 72 = 8.9 + 0 (so q = 9 and r = 0).

Aside: Observe that r = 0 precisely when a divides b; and that r > 0 if a ndivides b.
The greatest common divisor d of two integers a,b has three interesting properties: The first of these properties follows immediately from Property 1. The second property is the basis of the Euclidean algorithm method for finding the greatest common divisor d of two integers a,b, which is demonstrated below. The third property follows from retracing the steps of the Euclidean algorithm.

Example 2. To find the gcd of 234 and 180, perform the following steps.

  1. Draw 3 parallel vertical lines.
  2. Write 234 and 180 in the two internal columns.
  3. Divide the smaller number 180 into the larger 234. Write the quotient in the column adjacent to 234, and the remainder below 234.
  4. Repeatedly divide back and forth in a similar way to Step 3. until one number divides (evenly) into the other. At this point that number is the gcd.

234180
11801623
             
5418

Here 180 was divided into 234, it went once remainder 54; then 54 was divided into 180, it went 3 times remainder 18; and 18 divides 54 (so we stop) ... and so 18 is the gcd of 234 and 180. \par Working backwards we can also find x,y such that 234x + 180y = 18:

18 = 180 - 162
= 180 - 3.54
= 180 - 3(234 - 1.180)
= 4.180 - 3.234.

So x = 4 and y = -3 is one possibility. All pairs x,y satisfy

x = 4 + 13t
y = -3 - 10t

for some integer t.

Aside: To see the existence of other pairs x,y satisfying 234x + 180y = 18, observe that

18 = 4.180 - 3.234
= 4.180 - 3.234 + (234.180/18 )t -(234.180/18 )t
= (4 + 234/18 t).180 + ( - 3 - 180/18 t).234
= (4 + 13t).180 + ( - 3 - 10t).234.

Diophantine equations

We have just seen that if d = (a,b) then we can use the Euclidean Algorithm to find integers x,y that satisfy

ax + by = d.

What if the right - hand side of the above equation is not d? i.e. can we still solve

ax + by = c

for x,y when c ne d? The question is answered by the theorem, below.

Aside: Equations of the form: ax + by = c are examples of Diophantine Equations (after Diophantus, an ancient Greek who was the first known to study them).
We will need the following lemma to prove the theorem.

Lemma. If alpha,beta are non - zero relatively prime integers then all integer solutions of alpha X + beta Y = 0 for X,Y are of form

X = beta t,
Y = -alpha t,

where t in Z.

Proof: Assume alpha,beta in Z, alpha,beta ne 0 and (alpha,beta) = 1. Rearranging alpha X + beta Y = 0, we obtain

beta Y = -alpha X.

So beta divides -alpha X, and since (alpha,beta) = 1 we must have beta divides X, i.e. X = beta t for some integer t, whence Y = -alpha t.

box

Theorem. Let a,b,c in Z with a,b not both zero, and suppose d = (a,b). Then ax + by = c has a solution for x,y if and only if d divides c. Moreover, if a,b are both non - zero, d divides c, and x0,y0 is one solution of ax + by = c then all possible solution pairs are of form

x = x0 + beta t
y = y0 - alpha t

where alpha = a/d, beta = b/d and t in Z. (A `starting solution' x0,y0 is

x0 = x´q
y0 = y´q

where q = c/d and x´,y´ is a solution of ax + by = d and may be obtained by applying the Euclidean Algorithm to a,b.)

Proof: If there is a solution then ax + by = c for some integers x,y. Now d divides a and d divides b, so d divides ax + by = c by Property 1. Now we prove the converse direction. Suppose d divides c (so that c = dq for some integer q). From the Euclidean Algorithm we can find integers x´,y´ such that

ax´ + by´ = d.

Hence

a.x´q + b.y´q = dq = c.

That is, a solution of ax + by = c exists (since x0 = x´q, y0 = y´q is a solution). Now let us find the general solution when solutions exist. Suppose x,y is a solution. Then we have

ax + by = c
ax0 + by0 = c,

whence on subtracting the equations we obtain

a(x - x0) + b(y - y0) = 0,

and on dividing by d, we get

alpha(x - x0) + beta(y - y0) = 0,

where alpha = a/d, beta = b/d and we have alpha,beta relatively prime and both non - zero. So by the lemma the general solution for x - x0, y - y0 is given by

x - x0 = beta t,
y - y0 = -alpha t,

where t in Z, which on rearranging gives the general solution stated in the theorem.

box

Aside: When giving the general solution in the case where d divides c, the theorem required that both a,b be non - zero ... but if one checks the given solutions still work if one or other of a,b is zero. So why include the restriction? ... The trouble is there are other solutions, e.g. suppose b = 0, i.e. we wish to solve ax + 0.y = c where d = a divides c. Then the solution for x is correct but notice it is just a complicated way of writing x = c/a, but y is allowed to be any integer (whereas the solution `suggests' some integers don't work ... depending on what choice you take for y0).