UK Mathematics Trust Webinar
Modular Arithmetic
Congruence and Remainders
Modular arithmetic is a way of comparing numbers by their remainders after division by a fixed positive integer, called the modulus. For example, when working modulo 10, numbers are compared according to their remainders upon division by 10.
The notation
is read as “a is congruent to b modulo n.” It means that a and b differ by a multiple of n:
Equivalently, a and b leave the same remainder when divided by n.
For instance, 3248 leaves remainder 8 when divided by 10. This can be expressed in several equivalent ways:
3248 and 3208 leave the same remainder when divided by 10.
3248 is 8 more than a multiple of 10.
3248=8+10k for some whole number k.
3248−8 is divisible by 10.
10 is a factor of 3248−8.
3248≡8(mod10).
These statements describe the same underlying relationship in different forms. The congruence notation is a compact shorthand for it.
Congruence is not ordinary equality
A congruence does not necessarily say that the two numbers are equal. It says they behave alike with respect to the chosen modulus. For example,
because 3248−78=3170, which is divisible by 10. The numbers 3248 and 78 are different, but they have the same remainder modulo 10.
The remainder is usually written as one of the integers from 0 to n−1. However, the number on the right side of a congruence can be any integer in the same congruence class. Thus, modulo 3,
Each number differs from 47 by a multiple of 3. In particular, 47−(−1)=48 is divisible by 3.
There are infinitely many integers congruent to a given number modulo n. By contrast, there are only n distinct remainder classes modulo n, usually represented by 0,1,…,n−1.
Key definition: a≡b(modn) exactly when a−b is divisible by n.
Working with Congruences
Finding a congruence class
To reduce a number modulo n, find its remainder after division by n. For example,
because 47 leaves remainder 2 when divided by 3.
To compare two numbers, subtract them and test whether the difference is divisible by the modulus. For example,
because 247−47=200 is not divisible by 3. Indeed, 47 leaves remainder 2 modulo 3, while 247 leaves remainder 1.
A difference of zero is divisible by every nonzero integer: 0=n⋅0. Therefore, every number is congruent to itself modulo n.
Adding and multiplying modulo a number
Congruences can be used before carrying out a large calculation. If numbers are replaced by congruent numbers, their sums and products remain congruent modulo the same modulus. This makes it possible to simplify calculations while preserving the final remainder.
For example, modulo 4:
Therefore,
This agrees with the direct calculation 37+59=96, which is divisible by 4.
For multiplication, the same reduction applies:
Thus the product leaves remainder 3 when divided by 4, without requiring the full multiplication.
The method is especially useful when numbers grow rapidly, such as when calculating a large power. Reducing modulo n at each step can keep intermediate values small, which is useful for hand calculations and computer calculations.
A Visual Model: Wrapping the Number Line
A useful way to picture arithmetic modulo n is to imagine the number line wrapped around a circle or cylinder with n positions.
For modulo 7, the positions correspond to the seven remainders 0 through 6. Starting at 0 and counting upward, each new group of seven returns to the same positions:
7 lies above 0 because 7≡0(mod7).
8 lies above 1 because 8≡1(mod7).
14 lies above 0 because 14≡0(mod7).
Negative numbers wrap around in the other direction: −1≡6(mod7).
Numbers in the same position are congruent modulo 7. For example,
are all congruent modulo 7. Similarly, −1,6,13,20 all belong to the same congruence class modulo 7.
This picture explains why there are only n different classes modulo n, even though infinitely many integers belong to each class.
Multiplication Tables Modulo a Number
A multiplication table modulo n records products by their congruence classes. It has n row headings and n column headings, usually 0,1,…,n−1. Each product is reduced to its representative from that same set.
Multiplication table modulo 5
Using the headings 0,1,2,3,4, the rows are:
Row 0: 0,0,0,0,0
Row 1: 0,1,2,3,4
Row 2: 0,2,4,1,3
Row 3: 0,3,1,4,2
Row 4: 0,4,3,2,1
For example, 2⋅3=6, and 6≡1(mod5), so the entry in row 2, column 3 is 1. The ordinary product is still 6; the table records its value modulo 5.
Likewise, 4⋅4=16≡1(mod5), so the bottom-right entry is 1.
Choosing the headings
Any one representative from each congruence class can be used as a heading. For a table modulo 5, possible sets include 0,1,2,3,4 or −2,−1,0,1,2. The headings need to represent each class exactly once.
Using 0,1,…,n−1 makes it easy to compare and recognize patterns. Entries are normally reduced to these representatives; for example, 6 is written as 1 in a modulo-5 table because 6≡1(mod5).
Patterns in the tables
Several patterns follow from the arithmetic:
Zero row and column: Multiplying any number by 0 gives 0, so the first row and first column contain only zeros.
Diagonal symmetry: The table is symmetric across the diagonal from the top-left to the bottom-right. This is because multiplication is commutative: a⋅b=b⋅a.
Final row and column: The last heading is n−1, which is congruent to −1 modulo n. Thus, multiplying by n−1 is equivalent to multiplying by −1, producing the negatives of the headings. In representatives 0,1,…,n−1, this row and column count backward through the classes.
Repeated patterns: Rows may contain repeating sequences. For example, in the modulo-5 table, multiplying by 2 gives the row 0,2,4,1,3.
Patterns can depend on the modulus. For instance, modulo 10, the result of a multiplication can be recorded using only its units digit, because two integers are congruent modulo 10 exactly when they have the same units digit.
An additional symmetry modulo 5
The modulo-5 multiplication table also has a symmetry across the other diagonal, from the bottom-left to the top-right, when entries are arranged in the usual order. This is not the ordinary commutative symmetry.
For example, the entries 3⋅1 and 4⋅2 are both congruent to 3 modulo 5. Rewriting the headings in equivalent forms helps explain the pattern:
So 4⋅2 is congruent to (−1)(−3)=3, matching 3⋅1=3. The pattern comes from the way negative representatives interact modulo 5. Similar patterns can be investigated in tables for other moduli rather than assumed to occur identically in every case.
Divisibility Tests and Squares
Modular arithmetic explains familiar divisibility rules. In base ten, the powers of 10 satisfy
A number written with decimal digits can therefore be replaced modulo 9 by the sum of its digits. For example, the number 3248 is congruent modulo 9 to
and 17≡8(mod9). Consequently, a number and the sum of its digits have the same remainder modulo 9. This gives the usual test for divisibility by 9‘;thesamereasoningalsosupportsthetestfordivisibilityby3$.
Multiplication tables can also help rule out whether a number is a square. A square modulo n must appear among the products of a number by itself, found on the main diagonal of the multiplication table. For example, modulo 4, the possible square remainders are only 0 and 1:
Therefore, an integer congruent to 2 or 3 modulo 4 cannot be a perfect square. Checking several moduli can give stronger ways to rule out a proposed square.
Further Uses
Modular arithmetic appears in mathematics, computing, and cryptography.
Large calculations: Repeated reduction modulo a fixed number prevents intermediate values from becoming unnecessarily large.
Cryptography: Encryption and decryption systems use modular arithmetic to transform numbers while allowing intended users to recover the original information. The RSA cryptosystem is a widely used example whose operations involve modular exponentiation.
Remainder constraints: A problem may specify the remainders of an unknown number upon division by several different integers. The Chinese remainder theorem describes when such conditions can be combined into a solution, especially when the moduli are pairwise coprime.
Prime moduli: Fermat’s little theorem is a result about powers modulo a prime. If p is prime and p does not divide a, then
ap−1≡1(modp).It is useful in number theory and is related to methods used in modular computation and cryptography.
The same core idea underlies all these applications: integers can be replaced by simpler representatives of their congruence classes whenever the calculation only depends on the remainder.

Ask anything
We've read this whole study set, so questions about it get the best answers.