Chapter 4 The fundamental theorem of arithmetic

advertisement
Chapter 4
The fundamental theorem of
arithmetic
We prove two important results in this chapter: the fact that every natural
number greater than or equal to 2 can be written uniquely as a product of
powers of primes — this is the fundamental theorem of arithmetic — and
the proof that certain numbers are irrational.
4.1
Writing numbers down
We begin at the beginning by reviewing how numbers are dealt with graphically.
4.1.1
From tallies to the positional number system
I don’t think our hunter-gatherer ancestors worried too much about writing
numbers down because there wasn’t any need: they didn’t have to fill in
tax-returns and so didn’t need accountants. However, organizing cities does
need accountants and so ways had to be found of writing numbers down.
The simplest way of doing this is to use a mark like |, called a tally, for each
thing being counted. So
||||||||||
means 10 things. This system has advantages and disadvantages. The advantage is that you don’t have to go on a training course to learn it. The
77
78 CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
disadvantage is that even quite small numbers need a lot of space like
||||||||||||||||||||||||||||||||||||||
It’s also hard to tell whether
|||||||||||||||||||||||||||||||||||||||
is the same number or not. (It’s not.) It’s inevitable that people will introduce abbreviations to make the system easier to use. Perhaps it was in
this way that the next development occurred. Both the ancient Egyptians
and Romans used similar systems but I’ll describe the Roman system because
it involves letters rather than pictures. First, you have a list of basic symbols:
number
symbol
1
I
5
V
10
X
50
L
100
C
500
D
1000
M
There are more symbols for bigger numbers. Numbers are then written
according to the additive principle. Thus MMVIIII is 2009. Incidently, I
understand that the custom of also using a subtractive principle so that, for
example, IX means 9 rather than using VIIII, is a more modern innovation.
This system is clearly a great improvement on the tally-system. Even quite
big numbers are written compactly and it is easy to compare numbers. On
the other hand, there is more to learn. The other disadvantage is that we need
separate symbols for different powers of 10 and their multiples by 5. This
was probably not too inconvenient in the ancient world where it is likely that
the numbers needed on a day-to-day basis were never going to be that big.
A common criticism of this system is that it is hard to do multiplication in.
However, that turns out to be a non-problem because, like us, the Romans
used pocket calculators or, more accurately, a device called an abacus that
could easily be carried under a toga. The real evidence for the usefulness of
this system of writing numbers is that it survived for hundreds and hundreds
of years.
The system used throughout the world today is quite different and is
called the positional number system. It seems to have been in place by the
ninth century in India but it was hundreds of years in development and the
result of ideas from many different cultures: the invention of zero on its own
4.1. WRITING NUMBERS DOWN
79
is one of the great steps in human intellectual development. The genius of
the system is that it requires only 10 symbols
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
and every natural number can be written using a sequence of these symbols.
The trick to making the system work is that we use the position on the page
of a symbol to tell us what number it means. Thus 2009 means
103
2
102
0
101
0
100
9
In other words
2 × 103 + 0 × 102 + 0 × 101 + 9 × 100 .
Notice the important rôle played by the symbol 0 which makes it clear which
column a symbol belongs in otherwise we couldn’t tell 29 from 209 from
2009. The disadvantage of this system is that you do have to go on a course
to learn it because it is a highly sophisticated way of writing numbers. On the
other hand, it has the enormous advantage that any number can be written
down in a compact way. Once the basic system had been accepted it could
be adapted to deal not only with positive whole numbers but also negative
whole numbers, using the symbol −, and also fractions with the introduction
of the decimal point. By the end of the sixteenth century, the full decimal
system was in place.
Notation warning! In the UK, we use a raised decimal point like 0 · 123
and not a comma. Also we generally write the number 1 without a long
hook at the top. If you do write it like that there is a danger that people will
confuse it with the number 7 which is not always written in the UK with a
line through it.
4.1.2
Number bases
We shall now look in more detail at the way in which numbers can be written
down using a positional notation. In order not to be biased, we shall not just
80 CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
work in base 10 but show how any base can be used. There is one result that
we shall use throughout this section. You can take it as an axiom, but I shall
set a proof as one of the exercises.
Lemma 4.1.1 (Remainder Theorem). Let a and b be integers where b > 0.
Then there are unique integers q and r such that
a = bq + r
where 0 ≤ r < b.
The number q is called the quotient and the number r is called the remainder. For example, if we consider the pair of natural numbers 14 and 3
then
14 = 3 · 4 + 2
where 4 is the quotient and 2 is the remainder.
Let me say a little more about the Remainder Theorem. Your first reaction to it should probably be that it looks obvious. You might conclude
from that that it is therefore uninteresting. But this would be wrong. It is
certainly not hard to understand but despite that it is important. The reason
is that whenever we have a question that involves divisibility, it is very likely
going to require the use of this result. For example, it is this result that tells
us that odd numbers are precisely those that leave remainder 1 when divided
by 2.
Let a and b be integers. We say that a divides b or that b is divisible by
a if there is a q such that b = aq. In other words, there is no remainder. We
also say that a is a divisor or factor of b. We write a | b to mean the same
thing as ‘a divides b’.
Warning! a | b does not mean the same thing as ab . The latter is a number,
the former is a statement about two numbers.
Let’s see how to represent numbers in base b where b ≥ 2. If d ≤ 10 then
we represent numbers by sequences of symbols taken from the set
Zd = {0, 1, 2, 3, . . . d − 1}
but if d > 10 then we need new symbols for 10, 11, 12 and so forth. It’s
convenient to use A,B,C, . . .. For example, if we want to write numbers in
4.1. WRITING NUMBERS DOWN
81
base 12 we use the set of symbols
{0, 1, . . . , 9, A, B}
whereas if we work in base 16 we use the set of symbols
{0, 1, . . . , 9, A, B, C, D, E, F }.
If x is a sequence of symbols then we write xd to make it clear that we are
to interpret this sequence as a number in base d. Thus BAD16 is a number
in base 16.
The symbols in a sequence xd , reading from right to left, tell us the contribution each power of d such as d0 , d1 , d2 , etc makes to the number the
sequence represents. Here are some examples.
Examples 4.1.2. Converting from base d to base 10.
1. 11A912 is a number in base 12. This represents the following number
in base 10:
1 × 123 + 1 × 122 + A × 121 + 9 × 120 ,
which is just the number
123 + 122 + 10 × 12 + 9 = 2001.
2. BAD16 represents a number in base 16. This represents the following
number in base 10:
B × 162 + A × 161 + D × 160 ,
which is just the number
11 × 162 + 10 × 16 + 13 = 2989.
3. 55567 represents a number in base 7. This represents the following
number in base 10:
5 × 73 + 5 × 72 + 5 × 71 + 6 × 70 = 2001.
These examples show how easy it is to convert from base d to base 10.
82 CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
There are two ways to convert from base 10 to base d.
1. The first runs in outline as follows. Let n be the number in base 10
that we wish to write in base d. Look for the largest power m of d such
that adm ≤ n where a < d. Then repeat for n − adm . Continuing in
this way, we write n as a sum of multiples of powers of d and so we can
write n in base d.
2. The second makes use of the remainder theorem. The idea behind this
method is as follows. Let
n = am . . . a1 a0
in base d. We may think of this as
n = (am . . . a1 )d + a0
It follows that a0 is the remainder when n is divided by d, and the
quotient is n0 = am . . . a1 . Thus we can generate the digits of n in base
d from right to left by repeatedly finding the next quotient and next
remainder by dividing the current quotient by d; the process starts with
our input number as first quotient.
Examples 4.1.3. Converting from base 10 to base d.
1. Write 2001 in base 7. I’ll solve this question in two different ways: the
long but direct route and then the short but more thought-provoking
route.
We see that 74 > 2001. Thus we divide 2001 by 73 . This goes 5 times
plus a remainder. Thus 2001 = 5 × 73 + 286. We now repeat with
286. We divide it by 72 . It goes 5 times again plus a remainder. Thus
286 = 5 × 72 + 41. We now repeat with 41. We get that 41 = 5 × 7 + 6.
We have therefore shown that
2001 = 5 × 73 + 5 × 72 + 5 × 7 + 6.
Thus 2001 in base 7 is just 5556.
4.1. WRITING NUMBERS DOWN
83
Now for the short method.
7
7
7
7
quotient
2001
285
40
5
0
remainder
6
5
5
5
Thus 2001 in base 7 is:
5556.
2. Write 2001 in base 12.
12
12
12
12
quotient
2001
166
13
1
0
remainder
9
10 = A
1
1
Thus 2001 in base 12 is:
11A9.
3. Write 2001 in base 2.
2
2
2
2
2
2
2
2
2
2
2
quotient
2001
1000
500
250
125
62
31
15
7
3
1
0
remainder
1
0
0
0
1
0
1
1
1
1
1
84 CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
Thus 2001 in base 2 is (reading from bottom to top):
11111010001.
When converting from one base to another it is always wise to check
your calculations by converting back.
Number bases have some special terminology associated with them which
you might encounter:
Base 2 binary.
Base 8 octal.
Base 10 decimal.
Base 12 duodecimal.
Base 16 hexadecimal.
Base 20 vigesimal.
Base 60 sexagesimal.
Binary, octal and hexadecimal occur in computer science; there are remnants
of a vigesimal system in French and the older Welsh system of counting; base
60 was used by astronomers in ancient Mesopotamia and is still the basis of
time measurement (60 seconds = 1 minute, and 60 minutes = 1 hour) and
angle measurement.
Exercises 4.1
1. Find the quotients and remainders for each of the following pair of
numbers. Divide the smaller into the larger.
(a) 30 and 6.
(b) 100 and 24.
(c) 364 and 12.
2. Write the number 2009 in
4.1. WRITING NUMBERS DOWN
85
(a) Base 5.
(b) Base 12.
(c) Base 16.
3. Write the following numbers in base 10.
(a) DAB16 .
(b) ABBA12 .
(c) 443322115 .
4. Prove the following properties of the division relation on Z.
(a) If a 6= 0 then a | a.
(b) If a | b and b | a then a = ±b.
(c) If a | b and b | c then a | c.
(d) If a | b and a | c then a | (b + c).
5. This question develops a proof of the remainder theorem. Let a and
b be integers with b > 0. Then there exist a unique pair of integers q
and r such that a = qb + r where 0 ≤ r < b.
(a) Let
X = {a − nb : n ∈ Z}.
Show that this set contains non-negative elements.
(b) Let X + be the subset of X consisting of non-negative elements.
This subset if non-empty by the first step. Use the well-ordering
principle to deduce that this set contains a minimum element r.
Thus r = a − qb ≥ 0 for some q ∈ Z.
(c) Show that if r ≥ b then X + in fact contains a smaller element,
which is a contradiction.
(d) We therefore have that a = bq + r where 0 ≤ r < b. It remains
to prove that q and r are unique with these propertries. Assume
therefore that a = bq 0 + r0 where 0 ≤ r0 < b. Deduce that q = q 0
and r = r0 .
86 CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
4.2
Greatest common divisors
The ideas in this section are simple but their ramifications substantial. Let
a, b ∈ N. A number d which divides both a and b is called a common divisor
of a and b. The largest number which divides both a and b is called the
greatest common divisor of a and b and is denoted by gcd(a, b). A pair of
natural numbers a and b is said to be coprime if gcd(a, b) = 1.
Note that for us gcd(0, 0) is undefined but that if a 6= 0 then gcd(a, 0) = a.
Example 4.2.1. Consider the numbers 12 and 16. The set of divisors of 12
is the set {1, 2, 3, 4, 6, 12}. The set of divisors of 16 is the set {1, 2, 4, 8, 16}.
The set of common divisors is the set of numbers that belong to both of
these two sets: namely, {1, 2, 4}. The greatest common divisor of 12 and 16
is therefore 4. Thus gcd(12, 16) = 4.
One application of greatest common divisors is in simplifying fractions.
is equal to the fraction 43 because we can divide
For example, the fraction 12
16
out the common divisor of numerator and denominator. The fraction which
results cannot be simplified further and is in its lowest terms.
Lemma 4.2.2. Let d = gcd(a, b). Then gcd( ad , db ) = 1.
Proof. Because d divides both a and b we may write a = a0 d and b = b0 d for
some natural numbers a0 and b0 . We therefore need to prove that gcd(a0 , b0 ) =
1. Suppose that e | a0 and e | b0 . Then a0 = ex and b0 = ey for some natural
numbers x and y. Thus a = exd and b = eyd. Observe that ed | a and ed | b
and so ed is a common divisor or both a and b. But d is the greatest common
divisor and so e = 1, as required.
Let me paraphrase what the result above says since it is not surprising. If
I divide two numbers by their greatest common divisor then the numbers that
remain are coprime. This seems intuitively plausible and the proof ensures
that our intuition is correct.
If the numbers a and b are large, then calculating their gcd in the way
I did above would be time-consuming and error-prone. We want to find
an efficient way of calculating the greatest common divisor. The following
lemma is the basis of just such an efficient method.
4.2. GREATEST COMMON DIVISORS
87
Lemma 4.2.3. Let a, b ∈ N, where b 6= 0, and let a = bq +r where 0 ≤ r < b.
Then
gcd(a, b) = gcd(b, r).
Proof. Let d be a common divisor of a and b. Since a = bq + r we have that
a − bq = r so that d is also a divisor of r. It follows that any divisor of a and
b is also a divisor of b and r.
Now let d be a common divisor of b and r. Since a = bq + r we have that
d divides a. Thus any divisor of b and r is a divisor of a and b.
It follows that the set of common divisors of a and b is the same as the
set of common divisors of b and r. Thus gcd(a, b) = gcd(b, r).
The point of the above result is that b < a and r < b. So calculating gcd(b, r) will be easier than calculating gcd(a, b) because the numbers
involved are smaller. Compare
z }| {
a = bq + r
with
a = bq + r .
| {z }
The above result is the basis of an efficient algorithm for computing greatest
common divisors. It was described in Propositions 1 and 2 of Book VII of
the Elements.
Algorithm 4.2.4 (Euclid’s algorithm).
Input: a, b ∈ N such that a ≥ b and b 6= 0.
Output: gcd(a, b).
Procedure: write a = bq + r where 0 ≤ r < b. Then gcd(a, b) = gcd(b, r). If
r 6= 0 then repeat this procedure with b and r and so on. The last non-zero
remainder is gcd(a, b)
Example 4.2.5. Let’s calculate gcd(19, 7) using Euclid’s algorithm. I have
highlighted the numbers that are involved at each stage.
19
7
5
2
=
=
=
=
7·2+5
5·1+2
2·2+1 ∗
1·2+0
88 CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
By Lemma 1.3.3 we have that
gcd(19, 7) = gcd(7, 5) = gcd(5, 2) = gcd(2, 1) = gcd(1, 0).
The last non-zero remainder is 1 and so gcd(19, 7) = 1 and, in this case, the
numbers are coprime.
There are occasions when we need to extract more information from Euclid’s algorithm as we shall discover later when we come to deal with prime
numbers.
Theorem 4.2.6 (Bézout’s theorem). Let a and b be natural numbers. Then
there are integers x and y such that
gcd(a, b) = xa + yb.
I shall prove this theorem by describing an algorithm that will compute
the integers x and y above. This is achieved by running Euclid’s algorithm
in reverse and is called the extended Euclidean algorithm. The procedure for
doing so is outlined below but the details are explained in the example that
follows it.
Algorithm 4.2.7 (Extended Euclidean algorithm).
Input: a, b ∈ N where a ≥ b and b 6= 0.
Output: numbers x, y ∈ Z such that gcd(a, b) = xa + yb.
Procedure: apply Euclid’s algorithm to a and b; working from bottom to top
rewrite each remainder in turn.
Example 4.2.8. This is a little involved so I have split the process up into
steps. I shall apply the extended Euclidean algorithm to the example I
calculated above. I have highlighted the non-zero remainders wherever they
occur, and I have discarded the last equality where the remainder was zero.
I have also marked the last non-zero remainder.
19 = 7 · 2 + 5
7 = 5·1+2
5 = 2·2+1 ∗
4.2. GREATEST COMMON DIVISORS
89
The first step is to rearrange each equation so that the non-zero remainder
is alone on the lefthand side.
5 = 19 − 7 · 2
2 = 7−5·1
1 = 5−2·2
Next we reverse the order of the list
1 = 5−2·2
2 = 7−5·1
5 = 19 − 7 · 2
We now start with the first equation. The lefthand side is the gcd we are
interested in. We treat all other remainders as algebraic quantities and systematically substitute them in order. Thus we begin with the first equation
1 = 5 − 2 · 2.
The next equation in our list is
2=7−5·1
so we replace 2 in our first equation by the expression on the right to get
1 = 5 − (7 − 5 · 1) · 2.
We now rearrange this equation by collecting up like terms treating the highlighted remainders as algebraic objects to get
1 = 3 · 5 − 2 · 7.
We can of course make a check at this point to ensure that our arithmetic is
correct. The next equation in our list is
5 = 19 − 7 · 2
so we replace 5 in our new equation by the expression on the right to get
1 = 3 · (19 − 7 · 2) − 2 · 7.
90 CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
Again we rearrange to get
1 = 3 · 19 − 8 · 7 .
The algorithm now terminates and we can write
gcd(19, 7) = 3 · 19 + (−8) · 7 ,
as required. We can also, of course, easily check the answer!
I shall describe a much more efficient algorithm for implementing the
extended Euclidean algorithm later in this book when I have discussed matrices.
The key application for the material of this section is the following.
Lemma 4.2.9. Let a and b be natural numbers. Then a and b are coprime
if, and only if, we may find integers x and y such that
1 = xa + yb.
Proof. Suppose first that a and b are coprime. By Bézout’s theorem
gcd(a, b) = ax + by
for some integers a and b. But, by assumption, gcd(a, b) = 1. Conversely,
suppose that
1 = xa + yb.
Then any natural number that divides both a and b must divide 1. It follows
that gcd(a, b) = 1.
The significance of the above lemma is that whenever you know that a and
b are coprime, you can actually write down an expression 1 = xa + yb which
actually means the same thing. This turns out to be enormously useful.
The greatest common divisor of two numbers a and b is the largest number
that divides into both a and b. On the other hand, if a | c and b | c then we
say that c is a common multiple of a and b. The smallest common multiple
of a and b is called the least common multiple of a and b and is denoted by
lcm(a, b). You might expect that to calculate the least common multiple we
would need a new algorithm, but in fact we can use Euclid’s algorithm as
the following result shows. I shall prove the following result later once I have
proved the fundamental theorem of arithmetic.
4.2. GREATEST COMMON DIVISORS
91
Proposition 4.2.10. Let a and b be natural numbers. Then
gcd(a, b) × lcm(a, b) = ab.
The notions of gcd and lcm play a natural role in the arithmetic of fractions. The key property of fractions is that a fraction ab is unchanged when
numerator and denominator are both multiplied by the same non-zero integer. Thus
ac
a
= .
b
bc
a
Given a fraction b we often want to simplify it as much as possible and this
is accomplished by calculating gcd(a, b) = d. We have a = a0 d and b = b0 d
and so
a0 d
a0
a
= 0 = 0.
b
bd
b
0 0
We have proved above that gcd(a , b ) = 1 and so the fraction cannot be
0
simplified any further. Thus ab0 is a fraction in its lowest terms. When we
come to add fractions, the problem is the reverse of simplification. We cannot
immediately add ab + dc because the denominators b and d are different. To
make progress, we have to rewrite each fraction so that their denominators
are the same. The simplest way to do this is to rewrite each fraction as a
fraction over bd by multiplying the first fraction by d and the second by b to
get
ad + bc
ad bc
+
=
.
bd bd
bd
However, the most efficient way is to write each fraction over lcm(b, d). Let
lcm(b, d) = b0 b = d0 d. Then
b0 a d 0 c
b0 a + d0 c
a c
+ = 0 + 0 =
.
b d
bb dd
lcm(b, c)
Exercises 4.2
1. Use Euclid’s algorithm to find the gcd’s of the following pairs of numbers.
(a) 35, 65.
(b) 135, 144.
92 CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
(c) 17017, 18900.
2. Use the extended Euclidean algorithm to find integers x and y such
that gcd(a, b) = ax + by for each of the following pairs of numbers. You
should ensure that your answers for x and y have the correct signs.
(a) 112, 267.
(b) 242, 1870.
3. Find the lowest common multiples of the following pairs of numbers.
(a) 22, 121.
(b) 48, 72.
(c) 25, 116.
4. We know how to find the greatest natural number that divides two
numbers. Define now gcd(a, b, c) to be the greatest common divisor of
a and b and c jointly. Prove that
gcd(a, b, c) = gcd(gcd(a, b), c).
Deduce that
gcd(gcd(a, b), c) = gcd(a, gcd(b, c)).
We may similarly define gcd(a, b, c, d) to be the greatest common divisor
of a and b and c and d jointly. Calculate gcd(910, 780, 286, 195) and
justify your calculations.
5. The following question is by Dubisch Amer. Math. Mon. 69. Define
N∗ = N \ {0}. A binary operation ◦ defined on N∗ is known to have
the following properties:
(a) a ◦ b = b ◦ a.
(b) a ◦ a = a.
(c) a ◦ (a + b) = a ◦ b.
Prove that a ◦ b = gcd(a, b). Hint: the question is not asking you to
prove that gcd(a, b) has these properties.
4.3. THE FUNDAMENTAL THEOREM OF ARITHMETIC
93
6. You have an unlimited supply of 3 cent stamps and an unlimited supply
of 5 cent stamps. By combining stamps of different values you can make
up other values: for example, three 3 cent stamps and two 5 cent stamps
make the value 19 cents. What is the largest value you cannot make?
Hint: you need to show that the question makes sense.
7. Let n ≥ 1. Define φ(n) to be the number of numbers less than n and
coprime to n. This is the Euler totient function. Tabulate the values
of φ(n) for 1 ≤ n ≤ 12.
4.3
The fundamental theorem of arithmetic
The goal of this section is to state and prove the most basic result about the
natural numbers: each natural number, excluding 0 and 1, can be written
as a product of powers of primes in essentially one way. The primes are
therefore the ‘atoms’ from which all natural numbers can be built.
4.3.1
Primes: the atoms of number
A proper divisor of a natural number n is a divisor that is neither 1 nor n.
A natural number n is said to be prime if n ≥ 2 and the only divisors of n
are 1 and n itself. A number bigger than or equal to 2 which is not prime is
said to be composite.
Warning! The number 1 is not a prime.
The properties of primes have exercised a great fascination ever since they
were first studied and continue to pose questions that mathematicians have
yet to solve. We shall just describe their basic properties in this section.
Lemma 4.3.1. Let n ≥ 2. Either n is prime or the smallest proper divisor
of n is prime.
Proof. Suppose n is not prime. Let d be the smallest proper divisor of n. If d
were not prime then d would have a smallest proper divisor and this divisor
would in turn divide n, but this would contradict the fact that d was the
smallest proper divisor of n. Thus d must itself be prime.
94 CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
The following was also proved by Euclid: it is Proposition 20 of Book IX
of Euclid.
Theorem 4.3.2. There are infinitely many primes.
Proof. Let p1 , . . . , pn be the first n primes. Put
N = (p1 . . . pn ) + 1.
If N is a prime, then N is a prime bigger than pn . If N is composite, then N
has a prime divisor p by Lemma 4.3.1. But p cannot equal any of the primes
p1 , . . . , pn because N leaves remainder 1 when divided by pi . It follows that
p is a prime bigger than pn . Thus we can always find a bigger prime. It
follows that there must be an infinite number of primes.
Algorithm 4.3.3. To decide √whether a number n is prime or composite.
Check to see if any prime p ≤ n divides n. If none of them do, the number
n is prime.
Let’s think about why this
divides n then we√can write n =√ab
√ works. If a√
for some number b. If a < n then b > n whilst if a > n then b < n.
Thus to decide if √
n is prime or not we need only carry out trial divisions by
all numbers a ≤ n. However, this is inefficient because if a divides n and
a is not prime then a is divisible by some prime p which must therefore also
divide
√ n. It follows that we need only carry out trial divisions by the primes
p ≤ n.
Example 4.3.4. Determine whether 97 is prime using the above √
algorithm.
We first calculate the largest whole number less than or equal to 97. This
is 9. We now carry out trial divisions of 97 by each prime number p where
2 ≤ p ≤ 9; by the way, if you aren’t certain which of these numbers is prime:
just try them all. You’ll get the right answer although not as efficiently. You
might also want to remember that if m doesn’t divide a number neither can
any multiple of m. In any event, in this case we carry out trial divisions by
2, 3, 5 and 7. None of them divides 97 exactly and so 97 is prime.
The following is the key property of primes we shall need to prove the
fundamental theorem of arithmetic. We use Bézout’s Theorem to prove it.
It is Proposition 30 of Book VII of Euclid.
4.3. THE FUNDAMENTAL THEOREM OF ARITHMETIC
95
Lemma 4.3.5 (Euclid’s lemma). Let p | ab where p is a prime. Then p | a
or p | b.
Proof. Suppose that p does not divide a. We shall prove that p must then
divide b. If p does not divide a, then a and p are coprime, and so there exist
integers x and y such that 1 = px + ay. Thus b = bpx + bay. Now p | bp and
p | ba, by assumption, and so p | b, as required.
Example 4.3.6. The above result is not true if p is not a prime. For example,
6 | 9 × 4 but 6 divides neither 9 nor 4.
Lemma 4.3.5 is so important, I want to spell out in words what it says
If a prime divides a product of numbers it must divide at least
one of them.
Theorem 4.3.7 (Fundamental theorem of arithmetic). Every number n ≥ 2
can be written as a product of primes in one way if we ignore the order in
which the primes appear. By product we allow the possibility that there is
only one prime.
Proof. Let n ≥ 2. If n is already a prime then there is nothing to prove, so
we can suppose that n is composite. Let p1 be the smallest prime divisor of
n. Then we can write n = p1 n0 where n0 < n. Once again, n0 is either prime
or composite. Continuing in this way, we can write n as a product of primes.
We now prove uniqueness. Suppose that
n = p1 . . . ps = q 1 . . . qt
are two ways of writing n as a product of primes. Now p1 | n and so p1 |
q1 . . . qt . By Euclid’s Lemma, the prime p1 must divide one of the qi ’s and,
since they are themselves prime, it must actually equal one of the qi ’s. By
relabelling if necessary, we can assume that p1 = q1 . Cancel p1 from both
sides and repeat with p2 . Continuing in this way, we see that every prime
occurring on the lefthand side occurs on the righthand side. Changing sides,
we see that every prime occurring on the righthand side occurs on the lefthand
side. We deduce that the two prime decompositions are identical.
When we write a number as a product of primes we usually gather together the same primes into a prime power, and write the primes in increasing
order which then gives a unique representation. This is illustrated in the example below.
96 CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
Example 4.3.8. Let n = 999, 999. Write n as a product of primes. There
are a number of ways of doing this but in this case there is an obvious place
to start. We have that
n = 32 ·111, 111 = 33 ·37, 037 = 33 ·7·5, 291 = 33 ·7·11·481 = 33 ·7·11·13·37.
Thus the prime factorisation of 999, 999 is
999, 999 = 33 · 7 · 11 · 13 · 37.
We can use the prime factorizations of numbers to give a nice proof of
Proposition 4.2.10. Let m and n be two integers. To keep things simple, we
suppose that their prime factorizations are
m = pα1 pβ2 pγ3 and n = pδ1 p2 pζ3
where p1 , p2 , p3 are primes. It will be obvious how to extend this argument
to the general case. The prime factorizations of gcd(m, n) and lcm(m, n) are
min(α,δ) min(β,) min(γ,ζ)
p3
p2
gcd(m, n) = p1
and
max(α,δ) max(β,) max(γ,ζ)
p3
p2
lcm(m, n) = p1
respectively. I shall let you work out why and also work out how we can use
these results to prove the above proposition.
4.3.2
Numerical partial fractions
This section is intended as motivation for the partial fraction representation
of rational functions described in a later chapter, so it can be omitted at first
reading. The idea is to show how a fraction be written as a sum of other
fractions having a particular shape. Specfically, the goal of this section is to
show how a proper fraction can be written as a sum of proper fractions over
prime power denominators. This involves two steps which I shall describe by
means of examples. The theory is an application of the fundamental theorem
or arithmetic and the extended Euclidean algorithm.
In order to add two fractions together, we first have to ensure that both
are expressed over the same denominator. For example, suppose we want to
8
add 57 and 13
. Since 7 × 13 = 91 we have the following
5
8
65 + 56
121
+
=
=
.
7 13
91
91
4.3. THE FUNDAMENTAL THEOREM OF ARITHMETIC
97
810
We shall now consider the reverse process, using the fraction 1003
as an
example. Observe that 1003 = 17 × 59 where 17 and 59 are coprime. Our
goal is to write
a
b
810
=
+
1003
17 59
for some natural numbers a and b. By the extended Euclidean algorithm, we
can write
1 = 7 · 17 − 2 · 59.
It follows that
1
7 · 17 − 2 · 59
7
2
=
=
− .
1003
17 · 59
59 17
Now multiply both sides by 810 to get
810
7 · 810 2 · 810
6
5
6
5
=
−
= 96 − 95 = 1 +
− .
1003
59
17
59
17
59 17
Simplifying we get
810
6
12
=
+
1003
59 17
as required.
We shall now do something different. Consider the fraction 10
. We have
16
4
that 16 = 2 and so we cannot write it as a product of coprime numbers.
However, we can do something else. We can write 10 = 2 + 8 = 21 + 23 . Thus
21 + 23
21 23
1
1
10
=
=
+ 4 = 3+ .
4
4
16
2
2
2
2
2
Thus
10
1
1
= 1 + 3.
16
2
2
Let’s now combine these two steps. Consider the fraction
factorisation of 90 is 2 · 32 · 5. Our first goal is to write
41
a
b
c
= + 2+ .
90
2 3
5
Thus we have to find a, b, c such that
41 = 45a + 10b + 18c.
41
.
90
The prime
98 CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
By trial and error, remembering that a, b, c have to be integers, we find that
41 = 45 · 1 + 10 · 5 + (−3) · 18.
It follows that
41
1
5
3
= + 2− .
90
2 3
5
We now want to write
5
e
d
= + 2
2
3
3 3
where |d| , |e| < 3. But 5 = 2 + 3 and so
5
1
2
= + 2.
2
3
3 3
It follows that
1 1 2 3
41
= + + − .
90
2 3 9 5
We may summarise what we have found in the following theorem.
Theorem 4.3.9.
(i) Let ab be a proper fraction, and let b = pn1 1 . . . pnr r be the prime factorisation
of b. Then
r
a X ci
=
b
pni
i=1 i
for some integers ci , where each of the fractions is proper.
(ii) Now let p be a prime and
c
pn
a proper fraction. Then
n
X dj
c
=
pn
pj
j=1
where each dj is such that |dj | < p.
4.3. THE FUNDAMENTAL THEOREM OF ARITHMETIC
4.3.3
99
The prime number theorem
There are no nice formulae to tell us what the nth prime is but there are still
some interesting results in this direction. The polynomial
p(n) = n2 − n + 41
has the property that its value for n = 1, 2, 3, 4, . . . , 40 is always prime. Of
course, for n = 41 it is clearly not prime. In 1971, the mathematician Yuri
Matijasevic found a polynomial in 26 variables of degree 25 with the property
that when non-negative integers are substituted for the variables the positive
values it takes are all and only the primes. However, this polynomial does
not generate the primes in any particular order.
If we adopt a statistical approach then we can obtain much more useful
results. The idea is that for each natural number n we count the number
of primes π(n) less than or equal to n. If we are going to do this then our
first problem is to compile a table of sufficiently many of them. The simplest
way of doing this is to use the Sieve of Eratosthenes. Suppose we want to
construct a table of all primes up to the number N . We begin by listing all
numbers from 2 to N inclusive. Mark 2 as prime and then cross out from the
table all numbers which are multiples of 2. The first number after 2 which
we have not crossed out is 3. We mark this as prime and then cross out all
multiples of 3. The first number after 3 not crossed out is 5. We mark this as
prime and continue in the same way. We stop when
√ we have crossed out all
multiples of the largest prime less than or equal to N . All marked numbers
will be prime as well as those numbers which remain not crossed out.
If you compile tables of primes in this way, you can calculate the function
π(x). Its graph has a staircase shape — it certainly isn’t smooth — but as
you zoom away it begins to look smoother and smoother. This raises the
question whether there is a smooth function that is a good approximation to
π(n). This seems to have been what Gauss did. He set up a table something
like the following (this is taken from LeVeque’s book Fundamentals of number
theory, Dover, 1977) where
∆(x) =
π(x) − π(x − 1000)
1000
100CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
represents an approximate slope of the curve π(x).
x
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
π(x)
168
303
430
550
669
783
900
1007
1117
1229
∆(x)
0 · 168
0 · 135
0 · 127
0 · 120
0 · 119
0 · 114
0 · 117
0 · 107
0 · 110
0 · 112
1
ln(x)
0 · 145
0 · 132
0 · 125
0 · 121
0 · 117
0 · 115
0 · 113
0 · 111
0 · 110
0 · 109
Gauss noticed, because that was the kind of person he was, that the slope of
1
. This suggests that the function, defined by
π(x) looked very much like ln(x)
integrating these slopes, is given by
Z x
1
li(x) =
dt
t=2 ln(t)
should be an approximation to π(x). It is called the logarithmic integral. Of
course, this is not a theorem: it is a conjecture. It was proved in 1896 by two
mathematicians: Hadamard in France and de la Vallée Poussin in Belgium.
Theorem 4.3.10 (The Prime Number Theorem (PNT): version 1).
π(x)
= 1.
x→∞ li(x)
lim
This version of the PNT is not that easy for us to use. However by
l’Hôpital’s rule, we can show that
li(x)
= 1.
x→∞ x/ ln(x)
lim
If we assume the first version of the PNT and use the above result, we obtain
the second version of the PNT.
Theorem 4.3.11 (The Prime Number Theorem: version 2).
π(x)
= 1.
x→∞ x/ ln(x)
lim
4.3. THE FUNDAMENTAL THEOREM OF ARITHMETIC
101
The above theorem can be interpreted as saying that for large values of
x
. This result is a huge
x the value of π(x) is approximately given by ln(x)
improvement on the theorem that there are infinitely many primes: it tells
us not only that there are infinitely many of them but also how they are
distributed.
Prime numbers also play an important role in computing: specifically, in
exchanging secret information. In 1976, Whitfield Diffie and Martin Hellman
wrote a paper on cryptography that can genuinely be called ground-breaking.
In ‘New directions in cryptography’ IEEE Transactions on Information Theory 22 (1976), 644–654, they put forward the idea of a public-key cryptosystem which would enable
. . . a private conversation . . . [to] be held between any two individuals regardless of whether they have ever communicated before.
With considerable farsightedness, Diffie and Hellman foresaw that such cryptosystems would be essential if communication between computers was to
reach its full potential. However, their paper did not describe a concrete way
of doing this. It was R. I. Rivest, A. Shamir and L. Adleman (RSA) who
found just such a concrete method described in their paper, ‘A method for
obtaining digital signatures and public-key cryptosystems’ Communications
of the ACM 21 (1978), 120–126. Their method is based on the following observation. Given two prime numbers it takes very little time to multiply them
together, but if I give you a number that is a product of two primes and ask
you to factorize it then it takes a lot of time. After considerable experimentation, RSA showed how to use little more than undergraduate mathematics
to put together a public-key cryptosystem that is an essential ingredient in
e-commerce. Ironically, this secret code had in fact been invented in 1973 at
GCHQ, who had kept it secret.
Exercises 4.3
1. List the primes less than 100.
2. For each of the following numbers use Algorithm 4.3.3 to determine
whether they are prime or composite. When they are composite find a
prime factorization. Show all working.
(a) 131.
102CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
(b) 689.
(c) 5491.
3. Given 24 · 3 · 55 · 112 and 22 · 56 · 114 , calculate their greatest common
divisor and least common multiple.
4. Use the
√fundamental theorem of arithmetic to show that we can always
write n, where n is a natural number, as a product of a natural
number and a product of square roots of primes. Calculate the square
roots of the following numbers exactly using the above method.
(a) 10.
(b) 42.
(c) 54.
5. Let a and b be coprime. Prove that if a | bc then a | c.
4.4
Modular arithmetic
From an early age, we are taught to think of numbers as being strung out
along the number line
−3
−2
−1
0
1
2
3
But that is not the only way we count. We count the seasons in a cyclic
manner
. . . autumn, winter, spring, summer . . .
and likewise the days of the week
. . . Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday . . .
Also the months of the year or the hours in a day, whether by means of the 12hour clock or the 24-hour clock. The fact that we use words for these events
obscures the fact that we really are counting. This is clearer in the names
for the months since October, November and December were originally the
eighth, ninth and tenth months, respectively, until Roman politics intervened
and they were shifted. But the counting in all these cases is not linear but
4.4. MODULAR ARITHMETIC
103
cyclic. Rather than using a number line to represent this type of counting,
we use instead number circles, and rather than using the words above, I
shall use numbers. Here is the number circle for the seasons with numbers
replacing words.
0
3
1
2
Adding in these systems of arithmetic means stepping around in a clockwise
direction, whereas subtracting means stepping around in an anticlockwise
direction. Modular arithmetic is the name given to these different systems of
cyclic counting. It was Carl Friedrich Gauss (1777–1855) who realised that
these different systems of counting were mathematically interesting.
4.4.1
Congruences
Let n ≥ 2 be a fixed natural number which in this context we call the
modulus. If a, b ∈ Z we write a ≡ b if, and only if, a and b leave the same
remainder when divided by n or, what amounts to the same thing, n | a − b.
Here are a couple of simple examples. If n = 2, then a ≡ b if, and only
if, a and b are either both odd or both even. On the other hand, if n = 10
then a ≡ b if, and only if, a and b have the same units digit.
The symbol ≡ is a modification of the equality symbol =. If a ≡ b with
respect to n we say that a is congruent to b modulo n. In fact, congruence
behaves like a weakened form of equality as we now show.
Lemma 4.4.1. Let n ≥ 2 be a fixed modulus.
1. a ≡ a.
2. a ≡ b implies b ≡ a.
104CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
3. a ≡ b and b ≡ c implies that a ≡ c.
4. a ≡ b and c ≡ d implies that a + c ≡ b + d.
5. a ≡ b and c ≡ d implies that ac ≡ bd.
Here is a very simple application of modular arithmetic.
Lemma 4.4.2. A natural number n is divisible by 9 if, and only if, the sum
of the digits of n is divisible by 9.
Proof. We shall work modulo 9. The proof hinges on the fact that 10 ≡ 1
modulo 9. By using Lemma 4.4.1, we quickly find that 10r ≡ 1 for all natural
numbers r ≥ 1. We use this result now. Let
n = an 10n + an−1 10n−1 + . . . + a1 10 + a0 .
Then n ≡ an + . . . + a0 . Thus n and the sum of the digits of n leave the same
remainder when divided by 9, and so n is divisible by 9 if, and only if, the
sum of the digits of n are divisible by 9.
Solving a linear equation such as ax+by = c is very easy. For each possible
real value of x we can compute the corresponding real value of y. But suppose
now that a, b and c are integers and we only want to find solutions (x, y) whose
co-ordinates are integers? This is an example of a Diophantine equation. We
shall show how it may solved with the help of modular arithmetic. First,
we shall show that the problem of finding integer solutions is equivalent to
solving a simple kind of liner equation in one unknown in modular arithmetic.
Lemma 4.4.3. Let a, b and c be integers. Then the following are equivalent.
1. The pair (x1 , y1 ) is an integer solution to ax + by = c for some y1 .
2. The integer x1 is a solution to the equation ax ≡ c (mod b).
Proof. (1) ⇒ (2). Suppose that ax1 + by1 = c. Then it is immediate that
ax1 ≡ c (mod b).
(2) ⇒ (1). Suppose that ax1 ≡ c (mod b). Then by definition, ax1 − c =
bz1 for some integer z1 . Thus ax1 + b(−z1 ) = c. We may therefore put
y1 = z1 .
4.4. MODULAR ARITHMETIC
105
We shall now describe how to solve all equations of the form
ax ≡ b (mod n).
Lemma 4.4.4. Consider the linear congruence ax ≡ b (mod n).
1. The linear congruence has a solution if, and only if, d = gcd(a, n) is
such that d | b.
2. If the condition in part (1) holds and x0 is any solution, then all solutions have the form
n
x = x0 + t
d
where t ∈ Z.
Proof. (1). Suppose first that x1 is a solution to our linear congruence. Then
by definition, ax1 −b = nq for some integer q. It follows that ax1 +n(−q) = b.
By definition d | a and d | n and so d | b.
We now prove the converse. By Bézout’s theorem, we may find integers
u and v such that au + nv = d. By assumption, d | b and so b = dw for some
integer w. It follows that auw + nvw = dw = b. Thus a(uw) ≡ b (mod n),
and we have found a solution.
(2) Let x0 be any one solution to ax ≡ b (mod n). It is routine to check
that x = x0 + t nd for any t ∈ Z. Let x1 be any solution to ax ≡ b (mod n).
Then a(x1 − x0 ) ≡ 0 (mod n). Thus a(x1 − x0 ) = tn for some integer t. The
result now follows.
There is a special case of the above result that is very important. Its
proof is immediate.
Corollary 4.4.5. Let p be a prime. Then the linear congruence ax ≡ b
(mod p), where a is not congruent to 0 modulo p, always has a solution, and
all solutions are congruent modulo p.
Example 4.4.6. Let’s find all the points on the line 2x + 3y = 5 that have
integer co-ordinates. Observe first that gcd(2, 3) = 1. Thus such points exist.
In this case, by inspection, 1 = 2 · 2 + (−1)3. Thus 5 = 10 · 2 + (−5)3. It
follows that (10, −5) is one point on the line with integer co-ordinates. Thus
the set of integer solutions is
{(10 + 3t, −5 − 2t) : t ∈ Z}.
106CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
4.4.2
Wilson’s theorem
I shall finish off this section with an application of congruences to primes.
It is the first hint of hidden patterns in the primes. We need some notation
first. For each natural number n define n!, pronounced n factorial, or if
you are more extrovert n shriek, as follows: 0! = 1 and for n > 0 define
n! = n · (n − 1)!. In other words, n! is what you get when you multiply
together all the positive integers less than or equal to n. For each natural
number n, we shall be interested in the value of (n − 1)! modulo n. Observe
that there is no point in studying n! (mod n) since the answer is always 0.
It’s worth doing some numerical calculations first to see if you can spot a
pattern.
Theorem 4.4.7 (Wilson’s Theorem). Let n be a natural number. Then n is
a prime if, and only if,
(n − 1)! ≡ n − 1
(mod n)
Since n − 1 ≡ −1 (mod n) this is usually expressed in the form
(n − 1)! ≡ −1
(mod n).
Proof. The statement to be proved is an ‘if, and only if’ and so we have to
prove two statements: (1) If n is prime then (n − 1)! ≡ n − 1 (mod n). (2)
If (n − 1)! ≡ n − 1 (mod n) then n is prime.
We prove (1) first. Let n be a prime. The result is clearly true when
n = 2 so we may assume n is an odd prime. For each 1 ≤ a ≤ n − 1 there
is a unique number 1 ≤ b ≤ n − 1 such that ab ≡ 1 (mod n). If a = b then
a1 ≡ 1 (mod n) which means that n | (a − 1)(a + 1). Since n is a prime
either n | a − 1 or a | a + 1. This can only occur if a = 1 or a = n − 1. Thus
(n − 1)! ≡ n − 1 (mod n), as claimed.
We now prove (2). Suppose that (n−1)! ≡ n−1 (mod n). We prove that
n is a prime. Observe that when n = 1 we have that (n − 1)! = 1 which is
not congruent to 0 modulo 1. When n = 4, we get that (4 − 1)! ≡ 2 (mod 4).
Suppose that n > 4 is not prime. Then n = ab where 1 < a, b < n. If a 6= b
then ab occurs as a factor of (n − 1)! and so this is congruent to 0 modulo n.
If a = b then a occurs in (n − 1)! and so does 2a. Thus n is again a factor of
(n − 1)!.
This theorem is interesting for another reason. To show that a number
is prime, we would usually apply the algorithm we described earlier which
4.5. RATIONAL VS. IRRATIONAL
107
is just a systematic way of carrying out trial division. This theorem shows
that a number is prime in a completely different way. Although it is not a
pratical test for deciding whether a number is prime or composite, since n!
gets very big very quickly, it shows that there might be backdoor ways of
showing that a number is prime. This is a very important question in the
light of the rôle of prime numbers in cryptography.
4.5
Rational vs. irrational
In Chapter 3, I described the set of real numbers in quite abstract terms. In
this section, I shall regard them from the point of view of decimal representations. This will lead to a new insight into the difference between rational
and irrational numbers.
4.5.1
Irrationals
Real numbers are the actual values of quantities such as mass length and time.
We cannot measure them exactly: the result of a measurement will always be
a rational number. We begin by proving that there are real numbers that are
not rationals. Recall the basic property of prime numbers: if a prime divides
the product of two numbers then it must divide at least of the numbers. We
use this property below. A real number which is not rational is said to be
irrational.
We may now generalize the result, obtained in Chapter 2, that
√
2 is irrational.
Theorem 4.5.1. The square root of every prime number is irrational.
√
Proof. We shall prove this by contradiction. Assume that we can write p
as a rational. I shall show that this assumption leads to a contradiction and
√
so must be false. We are assuming that p = ab . By cancelling the greatest
common divisor of a and b we can in fact assume that gcd(a, b) = 1. This
√
will be crucial to our argument. Squaring both sides of the equation p = ab
and multiplying the resulting equation by b2 we get that
pb2 = a2 .
This says that a2 is divisible by p. But if a prime divides a product of two
numbers it must divide at least one of those numbers by Euclid’s lemma.
108CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
Thus p divides a. Thus we can write a = pc for some natural number c.
Substituting this into our equation above we get that
pb2 = p2 c2 .
Dividing both sides of this equation by p gives
b2 = pc2 .
This tells us that b2 is divisible by p and so in the same way as above p
√
divides b. We have therefore shown that our assumption that p is rational
leads to both a and b being divisible by p. But this contradicts the fact that
√
gcd(a, b) = 1. Our assumption is therefore wrong, and so p is not a rational
number.
Irrational numbers abound: both e and π can be proved to be irrational,
for example. The discovery of irrational numbers is due to the Ancient Greeks
and was one of the first great mathematical discoveries.
Although we cannot calculate irrational numbers exactly, we can calculate
them to any degree of accuracy needed and it is by means of such approximations that irrational numbers
are handled practically. For example, suppose
√
we want
√ to calculate n where n is not a perfect square. Make a first guess
is in general a better
a to n. Put b = na . Then their average a0 = a+b
2
guess. This process can be repeated, as the following example illustrates,
and enables us to calculate square roots to any desired degree of accuracy.
√
Example 4.5.2. I shall calculate some approximations to 3 using the above
method. We observe that 12 < 3 < 22 so my first guess is 1. We have that
3
= 3 and the average of 1 and 3 is 2. I now start the process all over again
1
with 2 as my guess. We have that 32 = 1 · 5 and the average of 2 and 1 · 5
is 1 · 75. This is my new guess. The number 3 divided by 1 · 75 is 1 · 714
(approximately). The average of 1 · 75 and 1 · 714 is 1 · 732. My new guess
is 1 · 732. 3 divided by 1 · 732 is 1 · 732 to 3 decimal places. Observe that
(1 · 732)2 = 2 · 999 . . . which isn’t bad.
4.5.2
Decimal fractions
I shall describe in this section the decimal fractions which correspond to
rational numbers. To see what’s involved, let’s calculate some decimal fractions.
4.5. RATIONAL VS. IRRATIONAL
109
Examples 4.5.3.
(i)
1
20
(ii)
1
7
(iii)
= 0 · 05. This fraction has a finite decimal representation.
= 0 · 142857142857142857142857142857 . . .. This fraction has an infinite decimal representation, which consists of the same sequence of
numbers repeated. We abbreviate this decimal to 0 · 142857.
37
84
= 0 · 44047619. This fraction has an infinite decimal representation,
which consists of a non-repeating part followed by a part which repeats.
Case (ii) is said to be a purely periodic decimal whereas case (iii), which
is more general, is said to be ultimately periodic.
Proposition 4.5.4. A proper rational number ab in its lowest terms has a
finite decimal expansion if and only if b = 2m 5n for some natural numbers m
and n.
Proof. Let
a
b
have the finite decimal representation 0 · a1 . . . an . This means
a1
a2
an
a
=
+ 2 + ... + n.
b
10 10
10
The righthand side is just the fraction
a1 10n−1 + a2 10n−2 + . . . + an
.
10n
The denominator contains only the prime factors 2 and 5 and so the reduced
form will also only contain at most the prime factors 2 and 5.
To prove the converse, consider the proper fraction
a
2α 5β
.
If α = β then the denominator is 10α . If α 6= β then multiply the fraction by
a suitable power of 2 or 5 as appropriate so that the resulting fraction has
denominator a power of 10. But any fraction with denominator a power of
10 has a finite decimal expansion.
Proposition 4.5.5. An infinite decimal fraction represents a rational number if and only if it is ultimately periodic.
110CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
Proof. Consider the ultimately periodic decimal number
r = 0 · a1 . . . as b1 . . . bt .
We shall prove that r is rational. Observe that
10s r = a1 . . . as · b1 . . . bt
and
10s+t = a1 . . . as b1 . . . bt · b1 . . . bt .
From which we get that
10s+t r − 10s r = a1 . . . as b1 . . . bt − a1 . . . as
where the righthand side is the decimal form of some integer that we shall
call a. It follows that
a
r = s+t
10 − 10s
is a rational number.
The proof of the converse is based on the method we use to compute
the decimal expansion of m
. We carry out repeated divisions by n and at
n
each step of the computation we use the remainder obtained to calculate
the next digit. But there are only a finite number of possible remainders
and our expansion is assumed infinite. Thus at some point there must be
repetition.
Example 4.5.6. We shall write the ultimately periodic decimal 0 · 94̄. as a
proper fraction in its lowest terms. Put r = 0 · 94̄. Then
• r = 0 · 94̄.
• 10r = 9.444 . . .
• 100r = 94.444 . . ..
Thus 100r − 10r = 94 − 9 = 85 and so r = 85
. We can simplify this to r =
90
We can now easily check that this is correct.
Exercises 4.5
17
.
18
4.6. CONTINUED FRACTIONS
111
1. For each of the following fractions determine whether they have finite
or infinite decimal representations. If they have infinite decimal representations determine whether they are purely periodic or ultimately
periodic; in both cases determine the periodic block.
(a)
1
.
2
(b)
1
.
3
(c)
1
.
4
(d)
1
.
5
(e)
1
.
6
(f)
1
.
7
2. Write the following decimals as fractions in their lowest terms.
(a) 0 · 534.
(b) 0 · 2106.
(c) 0 · 076923.
4.6
Continued fractions
The goal of this section is to show how some of the ideas we have introduced
so far can interact with each other. The material we cover is not needed
elsewhere in this book.
4.6.1
Fractions of fractions
We return to an earlier calculation. We used Euclid’s algorithm to calculate
gcd(19, 7) as follows.
19
7
5
2
=
=
=
=
7·2+5
5·1+2
2·2+1
1·2+0
112CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
We first rewrite each line, except the last, as follows
19
5
= 2+
7
2
2
7
= 1+
5
5
1
5
= 2+
2
2
Take the first equality
But
5
7
19
5
=2+ .
7
2
7
is the reciprocal of 5 , and from the second equality
7
2
=1+ .
5
5
If we combine them, we get
1
19
=2+
7
1+
2
5
however strange this may look. We may repeat the process to get
19
=2+
7
1
1+
1
2+
1
2
Fractions like this are called continued fractions. Suppose I just gave you
1
2+
1+
1
2+
1
2
You could work out what the usual rational expression was by working from
the bottom up. First compute the part in bold below
1
2+
1+
1
2+
1
2
4.6. CONTINUED FRACTIONS
113
to get
1
2+
1+
1
5
2
which simplifies to
2+
1
1+
2
5
This process can no be repeated and we shall eventually obtain a standard
fraction.
I am not going to develop the theory of continued fractions, but I shall
show you one more application. Let r be a real number. We may write
r as r = m1 + r1 where 0 ≤ r1 < 1. For example, π may be written as
π = 3 · 14159265358 . . . where here m = 3 and r1 = 0 · 14159265358 . . .. Now
since r1 < 1 and assume that it is non-zero. Then r11 > 1. We may therefore
repeat the above process and write r11 = m2 + r2 where once again r2 < 1.
This begin to feel an aweful lot like what we did above. In fact, we may write
r = m1 +
1
,
m2 + r2
and we can continue the above process with r2 . It looks like we would obtain
a continued fraction representation of r with the big difference that it could
be infinite. Here is a concrete example.
√
√
Example 4.6.1. We apply the above process to 3. Clearly, 1 < 3 < 2.
Thus
√
√
3 = 1 + ( 3 − 1)
√
where 3 − 1 < 1. We now focus on
√
1
.
3−1
To
√ convert this into a more usable form we multiple top and bottom by
3 + 1. We therefore get that
√
1
1 √
= ( 3 + 1).
2
3−1
114CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
√
It is clear that 1 < 21 ( 3 + 1) < 1 12 . Thus
1
√
=1+
3−1
√
3−1
.
2
We now focus on
2
√
3−1
which simplifies to
√
3 + 1. Clearly
2<
√
3 + 1 < 3.
√
√
Thus 3 + 1 = 2 + ( 3 − 1). However, we have now gone full circle. Let’s
see what we have obtained. We have that
√
3=1+
1
1
√
1+
2 + ( 3 − 1)
.
However, we saw above that the pattern repeats as
actually have is
√
1
3=1+
.
1
1+
1
2+
1
1+
...
√
3 − 1, so what we
Let’s see where we are by computing
1
1+
1+
1
2+
1
1
which simplifies to 47 . You can check that this is an approximation to
√
3.
4.6. CONTINUED FRACTIONS
4.6.2
115
Rabbits and pentagons
We now illustrate some of the ways that algebra and geometry may interact. We begin with an artificial looking question. In his book, Liber Abaci,
Fibonacci raised the following little puzzle which I’ve taken from MacTutor:
“A certain man put a pair of rabbits in a place surrounded on
all sides by a wall. How many pairs of rabbits can be produced
from that pair in a year if it is supposed that every month each
pair begets a new pair which from the second month on becomes
productive?”
These are obviously mathematical rabbits rather than real ones so let me
spell out the rules more explicitly:
Rule 1 The problem begins with one pair of immature rabbits.1
Rule 2 Each immature pair of rabbits takes one month to mature.
Rule 3 Each mature pair of rabbits produces a new immature pair at the
end of a month.
Rule 4 The rabbits are immortal.
The important point is that we must solve the problem using the rules we
have been given. To do this, I am going to draw a picture. I will represent
an immature pair of rabbits by ◦ and a mature pair by •. Rule 2 will be
represented by
◦
•
and Rule 3 will be represented by
•@
~~
~~
~
~
~
@@
@@
@@
•
◦
Rule 1 tells us that we start with ◦. Applying the rules we obtain the following
picture for the first 4 months.
1
Fibonacci himself seems to have assumed that the starting pair was already mature
but we shan’t.
116CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
◦
1 pair
1 pair
•<
•
<<<
<<
<<
◦<
•<
<<
<<
<<
<<
<<
<
<<
<
◦
•<
•
<<
<<<
<<
<<
<<
<<
<
<
◦
•
•
2 pairs
3 pairs
◦
5 pairs
We start with 1 pair and at the end of the first month we still have 1 pair, at
the end of the second month 2 pairs, at the end of the third month 3 pairs,
and at the end of the fourth month 5 pairs. I shall write this F0 = 1, F1 = 1,
F2 = 2, F3 = 3, F4 = 5, and so on. Thus the problem will be solved if we
can compute F12 . There is an apparent pattern in the sequence of numbers
1, 1, 2, 3, 5, . . . after the first two terms in the sequence each number is the
sum of the previous two. Let’s check that we are not just seeing things.
Suppose that the number of immature pairs of rabbits at a given time t is
It and the number of mature pairs is Mt . Then using our rules at time t + 1
we have that Mt+1 = Mt + It and It+1 = Mt . Thus
Ft+1 = 2Mt + It .
Similarly
Ft+2 = 3Mt + 2It .
It is now easy to check that
Ft+2 = Ft+1 + Ft .
The sequence of numbers such that F0 = 1, F1 = 1 and satisfying the
rule Ft+2 = Ft+1 + Ft is called the Fibonacci sequence. We have that
F0 = 1, F1 = 1, F2 = 2, F3 = 3, F4 = 5, F5 = 8, F6 = 13, F7 = 21,
F8 = 34, F9 = 55, F10 = 89, F11 = 144, F12 = 233.
4.6. CONTINUED FRACTIONS
117
The solution to the original question is therefore 233 pairs of rabbits.
Fibonacci numbers arise in the most diverse situations: famously, in phyllotaxis which is the study of how leaves and petals are arranged on plants.
We shall now look for a formula that will enable us to calculate Fn directly.
To begin, we’ll follow an idea due to the astronomer Jonannes Kepler, and
as n gets bigger and bigger. I
look at the behaviour of the fractions FFn+1
n
have tabulated some calculations below.
F1
F0
F2
F1
1
2
F3
F2
F4
F3
F5
F4
F6
F5
F7
F6
F14
F13
1 · 5 1 · 6 1 · 625 1 · 615 1 · 619 1 · 6180
These ratios seem to be going somewhere; the question is: where? Notice
that
Fn + Fn−1
Fn−1
1
Fn+1
=
=1+
= 1 + Fn .
Fn
Fn
Fn
Fn−1
n
and FFn−1
will be almost the same.
But for very large n we suspect that FFn+1
n
This suggests, but doesn’t prove, that we need to find the positive solution
x to
1
x=1+ .
x
Thus x is a number that when you take its reciprocal and add 1 you get x
back again. This problem is really a quadratic equation in disguise
x2 = x + 1 or more usually x2 − x − 1 = 0.
This equation can be solved very simply to give us
√
1± 5
x=
.
2
That is
√
√
1+ 5
1− 5
φ=
and φ̄ =
.
2
2
The number φ is called the golden ratio, about which a deal of nonsense has
been written. Let’s go back and see if this calculation makes sense. First we
calculate φ and we get
φ = 1 · 618033988 . . .
I compute
F19
6765
=
= 1 · 618033963
F18
4181
118CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
on my pocket calculator. This is pretty close.
We can now get our formula for the Fibonacci numbers. Define
1
fn = √ φn+1 − φ̄n+1 .
5
I’m going to show you that Fn = fn . To do this, I’ll use the following
identities which are straightforward to check
√
φ − φ̄ = 5 φ2 = φ + 1 and φ̄2 = φ̄ + 1.
Let’s start with f0 . We know that
φ − φ̄ =
√
5
and so we really do have that f0 = 1. To calculate f1 we use the other
formulae and again we get f1 = 1. We now calculate fn + fn+1 we get
1
1
fn + fn+1 = √ φn+1 − φ̄n+1 + √ φn+2 − φ̄n+2
5
5
1
= √ φn+1 + φn+2 − (φ̄n+1 + φ̄n+2 )
5
1
= √ φn+1 (1 + φ) − φ̄n+1 (1 + φ̄)
5
1
= √ φn+1 φ2 − φ̄n+1 φ̄2
5
1
= √ φn+3 − φ̄n+3 = fn+2
5
Because fn and Fn start in the same place and satisfy the same rules, we
have therefore proved that
Fn = √15 φn+1 − φ̄n+1 .
At this point, we can go back and verify our original idea that the fractions
seem to get closer and closer to φ as n gets larger and larger. We have
that
Fn+1
Fn
Fn+1
φn+2 − φ̄n+2
=
Fn
φn+1 − φ̄n+1
φ
1
=
−
1 φ n+1
( )
−
1 − ( φ̄φ )n+1
φ̄ φ̄
1
φ̄
4.6. CONTINUED FRACTIONS
119
I have rewritten it like this so that we can see what happens as n gets larger
and larger. Observe that the absolute value of φφ̄ is less than 1. So as n gets
larger and larger the first term above gets closer and closer to φ. Now look
at the second term. The absolute value of the fraction φφ̄ is strictly greater
than 1. Thus as n gets larger and larger the denominator of the second term
gets larger and larger and so the fraction as a whole gets smaller and smaller.
Thus we have proved that FFn+1
really is close to φ when n is large.
n
So far, what we have been doing is algebra. I shall now show that there
is geometry here as well. Below is a picture of a regular pentagon. I have
assumed that the length of the sides is 1. I claim that the length of a diagonal,
such as BE, is equal to φ.
B
C
1
φ
A
D
E
To prove this I am going to use Ptolomy’s theorem. We shall concentrate on
the cyclic quadrilateral formed by the vertices ABDE.
B
C
A
D
E
I’ll let the side of a diagonal be x. Then by Ptolomy’s theorem, we have that
x2 = 1 + x.
120CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
But this is precisely the quadratic equation we solved above. Its positive
solution is φ and so the length of a diagonal of a regular pentagon with side
1 is φ.
This raises the question of whether we can somehow see the Fibonacci
numbers in the regular pentagon. The answer is: almost. Consider the
diagram below.
B
C
e0
d0
a0
b0
D
c0
A
E
I’ve drawn in all the diagonals. The shaded triangle BCD is similar to the
shaded triangle Ac0 E. This means that they have exactly the same shapes
just different sizes. It follows that
BC
Ac0
=
.
AE
BD
But AE is a side of the pentagon and so has unit length, and BD is of length
φ. Thus
1
AC 0 = .
φ
Now, Dc0 has the same length as BC which is a side of the pentagon. Thus
Dc0 = 1. We now have
φ = DA = Dc0 + c0 A = 1 +
Thus, just from geometry, we get
φ=1+
1
.
φ
1
.
φ
4.6. CONTINUED FRACTIONS
121
This is a very odd equation because φ is mentioned on both sides. Let’s go
with it and repeat:
1
φ=1+
1 + φ1
and
1
φ=1+
1+
and
1
1+
1
φ
1
φ=1+
1
1+
1+
1
1+
1
φ
and so on. We therefore obtain a continued fraction. For each of these
fractions cover up the term φ1 and then calculate what you see to get
1,
1+
1
= 2,
1
1+
1
1+
1
1
3
= ,
2
and the Fibonacci sequence reappears.
1
1+
1+
1
1+
5
= ,...
3
1
1
122CHAPTER 4. THE FUNDAMENTAL THEOREM OF ARITHMETIC
Download