Modulo arithmetic: remainders, equivalence and useful methods
What you will get from this section. You will learn what means and the basic rules of modulo arithmetic. You will then see how these rules can be used to solve problems that might otherwise be difficult, including some that could occur in the TMUA. Although modulo arithmetic is not required knowledge for the TMUA, and any question for which it is useful can also be solved using ordinary arguments about remainders and divisibility, it can turn lengthy calculations and proofs into very short ones. It is therefore an extremely useful and interesting additional technique to learn.
TMUA Relevance Score: 6/10
Basic definition
Let be a positive integer. We write
to mean that and have the same remainder upon division by . We read this as “ is equivalent to modulo ”.
For example, consider the numbers , , and . We have
- ;
- ;
- ;
- .
They all leave remainder when divided by , so
.
It is also often useful to characterise equivalence modulo in the following way:
if and only if divides .
This is equivalent to the first definition and is sometimes the more useful characterisation.
Adding and subtracting multiples of
We may add or subtract any multiple of from either side without changing the equivalence modulo .
If , then for any integers and .
Why is this true? If and have the same remainder modulo , then so do and , since adding or subtracting a multiple of does not change the remainder upon division by .
For example, . Adding , which is a multiple of , to gives
,
so the remainder is still .
As another example, means that and have the same remainder modulo . If we add to while subtracting from , neither remainder changes, so the resulting numbers remain equivalent modulo . We do not even need to know what the common remainder is—although, in this case, it is .
The most important takeaway intuition
means that we may regard and as the “same”, or as equal, modulo .
Equivalent is the most appropriate way to understand the relationship between such and . This is not equality in the ordinary sense, but they do have equal remainders upon division by .
Another way to envisage this is to put all integers into groups according to their remainder upon division by . Then and belong to the same group. This is what mathematicians call an equivalence relation, which satisfies three key properties:
- every integer is equivalent to itself;
- if , then ;
- if and , then .
This leads to the important basic operations that we can perform in modulo arithmetic. Although and are not equal in the ordinary sense, they are regarded as the same modulo . Consequently, some of the operations we can perform on ordinary equations can also be performed on equivalences modulo . This is the next intuition to build.
Basic properties
As mentioned above, we may treat almost like an equation when adding, subtracting and multiplying. There is, however, an important difference when we try to reverse these operations.
Adding to both sides
For any integer ,
.
The forward implication follows by adding to both sides. The converse follows by adding to both sides.
Multiplying both sides by
For every integer ,
.
This is less obvious, but it is always true. If divides , then it must also divide . Notice that the implication arrow only goes from left to right, unlike the equivalence for addition. The converse is not always true. For example, , but dividing both sides by would give , which is false.
Cancelling from both sides
The converse of multiplying both sides by would allow us to cancel a non-zero integer from both sides. As shown above, this is not valid in general. The exact condition is:
The implication is valid for all integers and if and only if .
First, we prove the if direction.
Suppose that and . Then divides . Since and have no prime factors in common, all the prime factors of , with their required multiplicities, must divide . Hence divides , so .
We now prove the only if direction by contradiction.
Suppose, for contradiction, that cancellation is valid for all integers and , but . Take and . Since divides , the number is divisible by . Therefore, .
However, since , we have , so is not divisible by . Hence . This contradicts our assumption that cancellation is valid for all integers and . Therefore, cancellation can be valid for all integers and only if .
Combining two equivalences
We can do more than add the same integer to, or multiply both sides of, a single equivalence modulo . We can also add, subtract and multiply two equivalences.
If and , then
,
,
.
Proof of the multiplication property
All the properties above can be proved directly from the basic definition. We will prove the least obvious one: if and , then .
Since , the difference is divisible by . Similarly, is divisible by . Now
Both terms on the right are divisible by , so their sum is divisible by . Therefore, divides , which proves that .
Raising both sides to a positive integer power
The multiplication property immediately gives a further useful rule. We may multiply by itself repeatedly to obtain
If , then for every positive integer .
This is perhaps the biggest cheat rule. For example, knowing that immediately tells us that for every positive even integer . You will see many problems shamelessly exploit this shortcut. 😊
Useful methods through TMUA-style examples
Modulo arithmetic develops into a deep topic studied further in university mathematics. For our purposes, however, we need no more than the basic results outlined above. The contrasting examples that follow demonstrate different techniques for using these results to shorten solutions and make the underlying logic easier to follow.
Example 1: Replacing a number inside an algebraic expression
An integer leaves remainder when divided by . What remainder does leave when divided by ?
We are given that . Since , we may use the more convenient representative instead. Applying the addition, multiplication and positive-power rules gives
.
The required remainder is .
Without modulo arithmetic, we could write , substitute this into the expression and expand. Modulo arithmetic avoids introducing and discards all multiples of immediately.
Technique: Replace numbers with the smallest or most convenient equivalent representatives throughout the calculation.
Example 2: Powers and repeating cycles
What is the remainder when is divided by ?
The powers of modulo repeat as
Indeed, , , and . Multiplying by once more returns us to , so the cycle repeats.
Similarly, you can verify that the powers of repeat as
Both cycles have length , and . The exponent therefore occupies the second position in each cycle, so
and .
Hence
,
so the required remainder is .
This particular example is not significantly simplified by modulo arithmetic, but it illustrates how modulo notation can make calculations and logical arguments more systematic and concise.
Technique: When powers repeat in a cycle, reduce the exponent modulo the length of the cycle to determine its position.
Example 3: Proving that an integer equation is impossible
Can integers , and satisfy
?
Every integer is equivalent modulo to one of , , or . Squaring these four representatives gives remainders , , and , respectively. Therefore, every square is equivalent to either or modulo .
It follows that can only be equivalent to , or modulo . However, . The two sides can never be equivalent modulo , so they cannot be equal. Therefore, the equation has no integer solutions.
A case-by-case argument based on whether and are even or odd would reach the same conclusion, but modulo arithmetic expresses all four cases together.
Technique: List the possible remainders of each side. If the two sets of possible remainders do not overlap, the equation has no integer solutions.
Example 4: Following a recurrence relation modulo
The sequence is defined by and .
For which positive integers is divisible by ?
We need only follow the remainders modulo :
The remainder has returned. Since each new remainder is determined entirely by the previous one, the same cycle must now repeat:
The remainder is every fourth term. Therefore, is divisible by precisely when is divisible by .
We could instead derive and study the remainders of the powers of . Following the recurrence directly is quicker.
Technique: Apply the recurrence directly to the remainders. Once the same state returns, all subsequent remainders repeat.
Example 5: The units digit of a power tower
Find the units digit of
The units digit of an integer is determined by its remainder modulo . The powers of modulo repeat in a cycle of length :
We therefore need to determine the remainder when the exponent is divided by .
Since and the exponent is odd,
Here, I replaced with because . Nice, right? 😊
The exponent therefore occupies the third position in the cycle of powers of modulo . Hence
so the units digit is .
Technique: For a power tower, determine only the remainder needed at each level rather than attempting to calculate the enormous exponent.
Summary
The statement means that and leave the same remainder when divided by . Working modulo , we can:
Replace numbers with the smallest or most convenient equivalent representatives throughout a calculation.
Add, subtract and multiply equivalences, and raise both sides to any positive integer power.
Cancel a non-zero integer from both sides when . This is the precise condition that guarantees cancellation in every case.