We have used the natural numbers to solve problems. This was the right set of numbers to work with in discrete mathematics because we always dealt with a whole number of things. The natural numbers have been a tool. Letās take a moment now to inspect that tool. What mathematical discoveries can we make
about the natural numbers themselves?
This is the main question of number theory: a huge, ancient, complex, and above all, beautiful branch of mathematics. Historically, number theory was known as the Queen of Mathematics and was very much a branch of
pure mathematics, studied for its own sake instead of as a means to understanding real-world applications. This has changed in recent years however, as applications of number theory have been unearthed. Probably the most well-known example of this is RSA cryptography, one of the methods used to encrypt data on the internet. It is number theory that makes this possible.
What sorts of questions belong to the realm of number theory? Here is a motivating example. Recall in our study of induction, we asked:
Which amounts of postage can be made exactly using just 5-cent and 8-cent stamps?
We were able to prove that
any amount greater than 27 cents could be made. You might wonder what would happen if we changed the denomination of the stamps. What if we instead had 4- and 9-cent stamps? Would there be some amount after which all amounts would be possible? Well, again, we could replace two 4-cent stamps with a 9-cent stamp, or three 9-cent stamps with seven 4-cent stamps. In each case we can create one more cent of postage. Using this as the inductive case would allow us to prove that any amount of postage greater than 23 cents can be made.
What if we had 2-cent and 4-cent stamps. Here it looks less promising. If we take some number of 2-cent stamps and some number of 4-cent stamps, what can we say about the total? Could it ever be odd? Doesnāt look like it.
Why does 5 and 8 work, 4 and 9 work, but 2 and 4 not work? What is it about these numbers? If I gave you a pair of numbers, could you tell me right away if they would work or not? We will answer these questions, and more, after first investigating some simpler properties of numbers themselves.
Subsection Divisibility
It is easy to add and multiply natural numbers. If we extend our focus to all integers, then subtraction is also easy (we need the negative numbers, so we can subtract any number from any other number, even larger from smaller). Division is the first operation that presents a challenge. If we wanted to extend our set of numbers so any division would be possible (maybe excluding division by 0), we would need to look at the rational numbers (the set of all numbers that can be written as fractions). This would be going too far, so we will refuse this option.
In fact, it is a good thing that not every number can be divided by other numbers. This helps us understand the structure of the natural numbers and opens the door to many interesting questions and applications.
If given numbers
and
it is possible that
gives a whole number. In this case, we say that
divides in symbols, we write
If this holds, then
is a divisor or factor of
and
is a multiple of
In other words, if
then
for some integer
(this is saying
is some multiple of
).
The Divisibility Relation.
Given integers and we say ā divides ā and write
provided is an integer. Thus the following assertions mean the same thing:
-
-
for some integer
-
is a factor (or divisor) of
-
is a multiple of
Notice that
is a statement. It is either true or false. On the other hand,
or
is some number. If we want to claim that
is not an integer, so
does not divide
then we can write
Example 6.2.1.
Decide whether each of the statements below are true or false.
-
-
-
-
-
-
-
-
-
Solution.
-
True. 4 āgoes intoā 20 five times without remainder. In other words,
an integer. We could also justify this by saying that
is a multiple of 4:
-
False. While 20 is a multiple of 4, it is false that
is a multiple of 20.
-
False.
is not even defined, let alone an integer.
-
True. In fact,
is true for all
This is because 0 is a multiple of every number:
-
True. In fact,
is true for all
-
True. 1 divides every number (other than 0).
-
True. Negative numbers work just fine for the divisibility relation. Here
It is also true that
and that
-
False. Both 8 and 12 are divisible by 4, but this does not mean that
is divisible by
-
This last example raises a question: How might one decide whether
Of course, if you had a trusted calculator, you could ask it for the value of
If it spits out anything other than an integer, you know
This seems a little like cheating though: We donāt have division, so should we really use division to check divisibility?
While we donāt really know how to divide, we do know how to multiply. We might try multiplying
by larger and larger numbers until we get close to
How close? Well, we want to be sure that if we multiply
by the next larger integer, we go over
For example, letās try this to decide whether Start finding multiples of 1642:
All of these are well less than 136299. I suppose we can jump ahead a bit:
Ah, so we need to look somewhere between 80 and 85. Try 83:
Is this the best we can do? How far are we from our desired 136299? If we subtract, we get So we know we cannot go up to 84; that will be too much. In other words, we have found that
Since
we can now safely say that
It turns out that the process we went through above can be repeated for any pair of numbers. We can always write the number
as some multiple of the number
plus some remainder. We know this because we know about
division with remainder from elementary school. This is just a way of saying it using multiplication. Due to the procedural nature that can be used to find the remainder, this fact is usually called the
division algorithm:
The Division Algorithm.
Given any two integers and we can always find an integer such that
where is an integer satisfying
The idea is that we can always take a large enough multiple of
so that the remainder
is as small as possible. We do allow the possibility of
in which case we have
Subsection Remainder Classes
The division algorithm tells us that there are only
possible remainders when dividing by
If we fix this divisor, we can group integers by the remainder. Each group is called a
remainder class modulo (or sometimes
residue class).
Example 6.2.2.
Describe the remainder classes modulo
Solution.
We want to classify numbers by what their remainder would be when divided by
From the division algorithm, we know there will be exactly 5 remainder classes, because there are only 5 choices for what
could be (
).
First consider Here we are looking for all the numbers divisible by since In other words, the multiples of 5. We get the infinite set
Notice we also include negative integers.
Next consider Which integers, when divided by 5, have remainder 1? Well, certainly 1 does, as does 6, and 11. Negatives? Here we must be careful: does NOT have remainder 1. We can write or but only one of these is a ācorrectā instance of the division algorithm: since we need to be non-negative. So in fact, to get we would have or etc. Thus we get the remainder class
There are three more to go. The remainder classes for and are, respectively
Note that in the example above,
every integer is in exactly one remainder class. The technical way to say this is that the remainder classes modulo
form a
partition of the integers. The most important fact about partitions is that it is possible to define an
equivalence relation from a partition: This is a relationship between pairs of numbers which acts in all the important ways like the āequalsā relationship.
All fun technical language aside, the idea is really simple. If two numbers belong to the same remainder class, then in some way, they are the same. That is, they are the same
up to division by . In the case where
above, the numbers
and
while not the same number, are the same when it comes to dividing by 5, because both have remainder
It matters what the divisor is:
and
are the same up to division by
but not up to division by
since
has a remainder of 1 when divided by 7 while 23 has a remainder of 2.
With all this in mind, letās introduce some notation. We want to say that and 23 are basically the same, even though they are not equal. It would be wrong to say Instead, we write But this is not always true. It works if we are thinking division by 5, so we need to denote that somehow. What we will actually write is this:
which is read, ā8 is congruent to 23 modulo 5ā (or just āmod 5ā). Of course then we could observe that
Congruence Modulo .
We say is congruent to modulo , and write,
provided and have the same remainder when divided by In other words, provided and belong to the same remainder class modulo
Many books define congruence modulo
slightly differently. They say that
if and only if
In other words, two numbers are congruent modulo
if their difference is a multiple of
So which definition is correct? It turns out that it doesnāt matter; they are equivalent.
To see why, consider two numbers and that are congruent modulo Then and have the same remainder when divided by We have
Here the two ās really are the same. Consider what we get when we take the difference of and
So
is a multiple of
or equivalently,
On the other hand, if we assume first that
so
then consider what happens if we divide each term by
Dividing
by
will leave some remainder, as will dividing
by
However, dividing
by
will leave 0 remainder. So the remainders on the left-hand side must cancel out. That is, the remainders must be the same.
Congruence and Divisibility.
For any integers and we have
It will also be useful to switch back and forth between congruences and regular equations. The above fact helps with this. We know that
if and only if
if and only if
for some integer
Rearranging that equation, we get
In other words, if
and
are congruent modulo
then
is
more than some multiple of
This conforms with our earlier observation that all the numbers in a particular remainder class are the same amount larger than the multiples of
Congruence and Equality.
For any integers and we have
Subsection Properties of Congruence
We said earlier that congruence modulo
behaves, in many important ways, the same way equality does. Specifically, we could prove that congruence modulo
is an
equivalence relation, which would require checking the following three facts:
Congruence Modulo is an Equivalence Relation.
Given any integers
and
and any positive integer
the following hold:
In other words, congruence modulo
is reflexive, symmetric, and transitive, and so is an equivalence relation.
You should take a minute to convince yourself that each of the properties above actually holds for congruence. Try explaining each using both the remainder and divisibility definitions.
Next, consider how congruence behaves when doing basic arithmetic. We already know that if you subtract two congruent numbers, the result will be congruent to 0 (be a multiple of
). What if we add something congruent to 1 to something congruent to 2? Will we get something congruent to 3?
Congruence and Arithmetic.
Suppose
and
Then the following hold:
The above facts might be written a little strangely, but the idea is simple. If we have a true congruence, and we add the same thing to both sides, the result is still a true congruence. This sounds like we are saying:
Of course this is true as well; it is the special case where
But what we have works in more generality. Think of congruence as being ābasically equal.ā If we have two numbers that are basically equal, and we add basically the same thing to both sides, the result will be basically equal.
This seems reasonable. Is it really true? Letās prove the first fact:
Proof.
Suppose and That means and for integers and Add these equations:
But
which is just a multiple of
So
or in other words,
The other two facts can be proved in a similar way.
One of the important consequences of these facts about congruences is that we can basically replace any number in a congruence with any other number it is congruent to. Here are some examples to see how (and why) that works:
Example 6.2.3.
Find the remainder of
divided by
Solution.
We could do long division, but there is another way. We want to find such that Now Of course so we can replace the 90 in the sum with 0. Why is this okay? We are actually subtracting the āsameā thing from both sides:
Next, note that
and
(since
). So we can in fact replace the 400 with simply a 4. Again, we are appealing to our claim that we can replace congruent elements, but we are really appealing to property 3 about the arithmetic of congruence: We know
so if we multiply both sides by
we get
Similarly, we can replace 3000 with 3, since So our original congruence becomes
Therefore divided by 9 has remainder 8.
The above example should convince you that the well-known divisibility test for 9 is true: The sum of the digits of a number is divisible by 9 if and only if the original number is divisible by 9. In fact, we now know something more: Any number is congruent to the sum of its digits, modulo 9.
Example 6.2.4.
Find the remainder when
is divided by 7.
Solution.
Of course, we are working with congruence because we want to find the smallest positive such that Now first write We have:
since Notice further that is congruent to 1 modulo 7. Thus we can simplify further:
In the above example, we are using the fact that if
then
This is just applying property 3 a bunch of times.
So far we have seen how to add, subtract, and multiply with congruences. What about division? There is a reason we have waited to discuss it. It turns out that we cannot simply divide. In other words, even if we do not know that Consider, for example,
This is true. Now and are both divisible by 6. However,
While this doesnāt work, note that
We cannot divide
by 6, but we can divide 8 by the greatest common factor of
and
Will this always happen?
Suppose
In other words, we have
for some integer
Of course
is divisible by
as is
So
must also be divisible by
Now if
and
have no common factors (other than 1), then we must have
But in general, if we try to divide
by
we donāt know that we will get an integer multiple of
Some of the
might get divided as well. To be safe, letās divide as much of
as we can. Take the largest factor of both
and
and cancel that out from
The rest of the factors of
will come from
no problem.
We will call the largest factor of both
and
the
for
greatest common divisor. In our example above,
since the greatest divisor common to 6 and 8 is 2.
Congruence and Division.
If
and
have no common factors, then
so
Example 6.2.5.
Simplify the following congruences using division: (a)
and (b)
Solution.
(a) Both and are divisible by and and have no common factors, so we get
(b) Again, we can divide by 3. However, doing so blindly gives us which is no longer true. Instead, we must also divide the modulus 15 by the greatest common factor of and which is Again we get
Subsection Solving Congruences
Now that we have some algebraic rules to govern congruence relations, we can attempt to solve for an unknown in a congruence. For example, is there a value of that satisfies,
and if so, what is it?
In this example, since the modulus is small, we could simply try every possible value for
There are really only 5 to consider, since any integer that satisfied the congruence could be replaced with any other integer it was congruent to modulo 5. Here, when
we get
which is indeed congruent to 4 modulo 5. This means that
and
and
and so on will each also be a solution because, as we saw above, replacing any number in a congruence with a congruent number does not change the truth of the congruence.
So in this example, simply compute
for values of
This gives 2, 5, 8, 11, and 14 respectively, for which only 14 is congruent to 4.
Letās also see how you could solve this using our rules for the algebra of congruences. Such an approach would be much simpler than the trial and error tactic if the modulus was larger. First, we know we can subtract 2 from both sides:
Then to divide both sides by 3, we first add 0 to both sides. Of course, on the right-hand side, we want that 0 to be a 10 (yes, really is 0 since they are congruent modulo 5). This gives,
Now divide both sides by 3. Since we do not need to change the modulus:
Notice that this in fact gives the
general solution: Not only can
but
can be any number which is congruent to 4. We can leave it like this, or write ā
for any integer
ā
Example 6.2.6.
Solve the following congruences for
Solution.
-
All we need to do here is divide both sides by 7. We add 13 to the right-hand side repeatedly until we get a multiple of 7 (adding 13 is the same as adding 0, so this is legal). We get ā got it. So we have:
-
Here, since we have numbers larger than the modulus, we can reduce them prior to applying any algebra. We have and Thus,
We got the 72 by adding to both sides of the congruence. Now divide both sides by 9. However, since we must divide the modulus by 3 as well:
So the solutions are those values that are congruent to 8, or equivalently 3, modulo 5. This means that in some sense there are 3 solutions modulo 15: 3, 8, and 13. We can write the solution:
-
First, reduce modulo 14:
We could now divide both sides by 3 or try to increase 9 by a multiple of 14 to get a multiple of 6. If we divide by 3, we get,
Now try adding multiples of 14 to 3, in hopes of getting a number we can divide by 2. This will not work! Every time we add 14 to the right side, the result will still be odd. We will never get an even number, so we will never be able to divide by 2. Thus there are no solutions to the congruence.
The last congruence above illustrates the way in which congruences might not have solutions. We could have seen this immediately in fact. Look at the original congruence:
If we write this as an equation, we get
or equivalently We can easily see there will be no solution to this equation in integers. The left-hand side will always be even, but the right-hand side is odd. A similar problem would occur if the right-hand side was divisible by any number that the left-hand side was not.
So in general, given the congruence
if and are divisible by a number by which is not divisible, then there will be no solutions. In fact, we really only need to check one divisor of and the greatest common divisor. Thus, a more compact way to say this is:
Congruences with No Solutions.
If
then
has no solutions.
Subsection Solving Linear Diophantine Equations
Discrete math deals with whole numbers of things. So when we want to solve equations, we usually are looking for
integer solutions. Equations that are intended to only have integer solutions were first studied by in the third century by the Greek mathematician Diophantus of Alexandria, and as such are called
Diophantine equations. Probably the most famous example of a Diophantine equation is
The integer solutions to this equation are called
Pythagorean triples. In general, solving Diophantine equations is hard (in fact, there is provably no general algorithm for deciding whether a Diophantine equation has a solution, a result known as Matiyasevichās Theorem). We will restrict our focus to
linear Diophantine equations, which are considerably easier to work with.
Diophantine Equations.
An equation in two or more variables is called a
Diophantine equation if only integer solutions are of interest. A
linear Diophantine equation takes the form
for constants
A
solution to a Diophantine equation is a solution to the equation consisting only of integers.
We have the tools we need to solve linear Diophantine equations. We will consider, as a main example, the equation
The general strategy will be to convert the equation to a congruence, and then solve that congruence. Letās work through this particular example to see how this might go.
First, check if perhaps there are no solutions because a divisor of and is not a divisor of Really, we just need to check whether This greatest common divisor is 3, and yes At this point, we might as well factor out this greatest common divisor. So instead, we will solve:
Now observe that if there are going to be solutions, then for those values of and the two sides of the equation must have the same remainder as each other, no matter what we divide by. In particular, if we divide both sides by 17, we must get the same remainder. Thus we can safely write
We choose 17 because will have remainder 0. This will allow us to reduce the congruence to just one variable. We could have also moved to a congruence modulo 29, although there is usually a good reason to select the smaller choice, as this will allow us to reduce the other coefficient. In our case, we reduce the congruence as follows:
Now at this point we know will work for any integer If we havenāt made a mistake, we should be able to plug this back into our original Diophantine equation to find
We have now found all solutions to the Diophantine equation. For each
and
will satisfy the equation. We could check this for a few cases. If
the solution is
and yes,
If
the solution is
If
we get
To summarize this process, to solve
we,
-
Divide both sides of the equation by
(if this does not leave the right-hand side as an integer, there are no solutions). Letās assume that
has already been reduced in this way.
-
Pick the smaller of and (here, assume it is ), and convert to a congruence modulo
This will reduce to a congruence with one variable,
-
Solve the congruence as we did in the previous section. Write your solution as an equation, such as,
-
Plug this into the original Diophantine equation, and solve for
-
If we want to know solutions in a particular range (for example,
), pick different values of
until you have all required solutions.
Example 6.2.7.
How can you make $6.37 using just 5-cent and 8-cent stamps? What is the smallest and largest number of stamps you could use?
Solution.
First, we need a Diophantine equation. We will work in numbers of cents. Let be the number of -cent stamps, and be the number of 8-cent stamps. We have:
Convert to a congruence and solve:
This says that one way to make $6.37 is to take 121 of the 5-cent stamps and 4 of the 8-cent stamps. To find the smallest and largest number of stamps, try different values of
|
|
Stamps |
|
|
|
-1 |
(129, -1) |
not possible |
0 |
(121, 4) |
125 |
1 |
(113, 9) |
122 |
2 |
(105, 13) |
119 |
|
|
|
This is no surprise. Having the most stamps means we have as many 5-cent stamps as possible, and to get the smallest number of stamps would require having the least number of 5-cent stamps. To minimize the number of 5-cent stamps, we want to pick
so that
is as small as possible (but still positive). When
we have
and
Therefore, to make $6.37, you can use as few as 80 stamps (1 5-cent stamp and 79 8-cent stamps) or as many as 125 stamps (121 5-cent stamps and 4 8-cent stamps).
Using this method, as long as you can solve linear congruences in one variable, you can solve linear Diophantine equations of two variables. There are times, though, that solving the linear congruence is a lot of work. For example, suppose you need to solve,
You could keep adding 51 to the right side until you get a multiple of 13: You would get 57, 108, 159, 210, 261, 312, and 312 is the first of these that is divisible by 13. This works but is really too much work. Instead we could convert back to a Diophantine equation:
Now solve this like we have in this section. Write it as a congruence modulo 13:
so Now go back and figure out
Of course you could do this switching back and forth between congruences and Diophantine equations as many times as you like. If you
only used this technique, you would essentially replicate the Euclidean algorithm, a more standard way to solve Diophantine equations.