Modular Arithmetic and Divisibility
Divisibility and Modular Arithmetic
Congruence and remainders
For integers a and b, and a positive integer m, the statement
means that a and b have the same remainder when divided by m. Equivalently, their difference is divisible by m:
Here, m∣(a−b) means that a−b is an integer multiple of m.
Key idea: Modular arithmetic groups integers according to their remainders after division by a fixed positive integer.
Possible remainders
When dividing an integer by m, its remainder is one of
These are the only possible remainders when using the standard division algorithm. A remainder of m is equivalent to a remainder of 0, since m is exactly divisible by m.
For example, modulo 4, the possible remainders are 0, 1, 2, and 3. The remainders repeat in a cycle as the integers increase:
0,4,8,… have remainder 0 modulo 4.
1,5,9,… have remainder 1 modulo 4.
2,6,10,… have remainder 2 modulo 4.
3,7,11,… have remainder 3 modulo 4.
The same cycle continues through negative integers. For example, −1 has remainder 3 modulo 4, because −1 and 3 differ by −4, which is divisible by 4.
Testing congruence using divisibility
To check whether two integers are congruent modulo m, subtract them and test whether the difference is divisible by m.
For example,
because
and 4 divides −4. The numbers 2 and 6 are not themselves divisible by 4;rather,theyarecongruentbecausetheirdifferenceisdivisibleby4.Theyalsobothleaveremainder2whendividedby4$.
In contrast,
because 24−14=10, and 6 does not divide 10. Equivalently, 24 leaves remainder 0 modulo 6, while 14 leaves remainder 2.
Congruence and the division algorithm
The division algorithm states that an integer can be written as a multiple of a positive integer plus a remainder. For an integer a and positive integer m, this has the form
where q is an integer and r is a remainder satisfying 0≤r<m. The remainder is also denoted by amodm.
Therefore, two integers are congruent modulo m exactly when their remainders are equal:
For example:
2=4⋅0+2, so 2mod4=2.
6=4⋅1+2, so 6mod4=2.
The remainders agree, confirming that 2≡6(mod4).
For another example:
24=6⋅4+0, so 24mod6=0.
14=6⋅2+2, so 14mod6=2.
The remainders differ, so 24≡14(mod6).
Three equivalent ways to recognize congruence
For integers a,b and positive integer m, the following statements are equivalent:
a≡b(modm).
m∣(a−b).
amodm=bmodm.
Each gives a different practical way to check a congruence: compare the numbers’ remainders, or check whether their difference is divisible by the modulus.
Congruence as an equation involving an integer multiple
A useful equivalent formulation is
Proof
Suppose first that a≡b(modm). By the definition of congruence, m∣(a−b). By the definition of divisibility, there is an integer k such that
Adding b to both sides gives
For the reverse direction, suppose that a=b+km for some integer k. Subtracting b gives
Thus m∣(a−b), and so a≡b(modm). This proves both directions of the equivalence.
Addition and multiplication preserve congruence
Let m be a positive integer. If
then both of the following congruences hold:
and
This means that numbers can be reduced to their remainders before adding or multiplying, provided the calculations are performed modulo the same positive integer.
Proof for addition
From the equation form of congruence, the assumptions imply that there are integers k and ℓ such that
Adding these equations gives
Thus (a+c)−(b+d) is a multiple of m, so
Proof for multiplication
Using the same expressions for a and c,
Expanding and collecting terms gives
The difference ac−bd is therefore a multiple of m, so
The addition and multiplication results are one-direction implications: if the original pairs are congruent modulo m, then their sums and products are congruent modulo m.
Computing with modular arithmetic
Calculations can be done either by evaluating the ordinary sum or product and then finding its remainder, or by reducing the numbers first and then carrying out the operation.
Addition modulo 5
Directly,
because 18 leaves remainder 3 when divided by 5.
Alternatively,
so the addition property gives
Multiplication modulo 5
Directly,
Alternatively, reducing the factors first gives
Both methods produce the same remainder.
Notation for modular operations
The notation +m indicates addition modulo m, while ×m indicates multiplication modulo m. The result is reduced to its remainder modulo m.
For example, modulo 3:
since 9 is divisible by 3. For multiplication,
since 20 leaves remainder 2 when divided by 3.

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