You are on page 1of 5

Modular arithmetic is the arithmetic of congruences, sometimes known informally as "clock arithmetic.

"
In modular arithmetic, numbers "wrap around" upon reaching a given fixed quantity, which is known as
the modulus (which would be 12 in the case of hours on a clock, or 60 in the case of minutes or seconds
on a clock).

Residue

We say that $a$ is the modulo-$m$ residue of $n$ when $n\equiv a\pmod m$, and $0\le a<m$.

Congruence

There is a mathematical way of saying that all of the integers are the same as one of the modulo 5
residues. For instance, we say that 7 and 2 are congruent modulo 5. We write this using the symbol
$\equiv$: In other words, this means in base 5, these integers have the same residue modulo 5:

$2\equiv 7\equiv 12 \pmod{5}.$

The (mod 5) part just tells us that we are working with the integers modulo 5. In modulo 5, two integers
are congruent when their difference is a multiple of 5. In general, two integers $a$ and $b$ are
congruent modulo $n$ when $a - b$ is a multiple of $n$. In other words, $a \equiv b \pmod{n}$ when
$\frac{a-b}{n}$ is an integer. Otherwise, $a \not\equiv b \pmod{n}$, which means that $a$ and $b$ are
not congruent modulo $n$.

Addition

Problem

Suppose we want to find the units digit of the following sum:

$2403 + 791 + 688 + 4339.$

We could find their sum, which is $8221$, and note that the units digit is $1$. However, we could find
the units digit with far less calculation.

Solution

We can simply add the units digits of the addends:


$3 + 1 + 8 + 9 = 21.$

The units digit of this sum is $1$, which must be the same as the units digit of the four-digit sum we
computed earlier.

Why we only need to use remainders

We can rewrite each of the integers in terms of multiples of $10$ and remainders:

$2403 = 240 \cdot 10 + 3$

$791 = 79 \cdot 10 + 1$

$688 = 68 \cdot 10 + 8$

$4339 = 433 \cdot 10 + 9$.

When we add all four integers, we get

$(240 \cdot 10 + 3) + (79 \cdot 10 + 1) + (68 \cdot 10 + 8) + (433 \cdot 10 + 9)$

$= (240 + 79 + 68 + 433) \cdot 10 + (3 + 1 + 8 + 9)$

At this point, we already see the units digits grouped apart and added to a multiple of $10$ (which will
not affect the units digit of the sum):

$= 820 \cdot 10 + 21 = 8200 + 21 = 8221$.

Solution using modular arithmetic

Now let's look back at this solution, using modular arithmetic from the start. Note that

$2403 \equiv 3 \pmod{10}$

$791 \equiv 1 \pmod{10}$

$688 \equiv 8 \pmod{10}$

$4339 \equiv 9 \pmod{10}$


Because we only need the modulo $10$ residue of the sum, we add just the residues of the summands:

$2403 + 791 + 688 + 4339 \equiv 3 + 1 + 8 + 9 \equiv 21 \equiv 1 \pmod{10},$

so the units digit of the sum is just $1$.

Addition rule

In general, when $a, b, c$, and $d$ are integers and $m$ is a positive integer such that

$a \equiv c \pmod{m}$

$b \equiv d \pmod{m}$

the following is always true:

$a + b \equiv c + d \pmod{m}$.

And as we did in the problem above, we can apply more pairs of equivalent integers to both sides, just
repeating this simple principle.

Proof of the addition rule

Let $a-c=m\cdot k$, and $b-d=m\cdot l$ where $l$ and $k$ are integers. Adding the two equations we
get: \begin{eqnarray*} mk+ml&=&(a-c)+(b-d)\\ m(k+l)&=&(a+b)-(c+d) \end{eqnarray*}

Which is equivalent to saying $a+b\equiv c+d\pmod{m}$

Subtraction

The same shortcut that works with addition of remainders works also with subtraction.

Problem

Find the remainder when the difference between $60002$ and $601$ is divided by $6$.

Solution

Note that $60002 = 10000 \cdot 6 + 2$ and $601 = 100 \cdot 6 + 1$. So,

$60002 \equiv 2 \pmod{6}$


$601 \equiv 1 \pmod{6}$

Thus,

$60002 - 601 \equiv 2 - 1 \equiv 1 \pmod{6},$

so 1 is the remainder when the difference is divided by $6$. (Perform the subtraction yourself, divide by
$6$, and see!)

Subtraction rule

When $a, b, c$, and $d$ are integers and $m$ is a positive integer such that

$a \equiv c \pmod{m}$

$b \equiv d \pmod{m}$

the following is always true:

$a - b \equiv c - d \pmod{m}$

Multiplication

Modular arithmetic provides an even larger advantage when multiplying than when adding or
subtracting. Let's take a look at a problem that demonstrates the point.

Problem

Jerry has $44$ boxes of soda in his truck. The cans of soda in each box are packed oddly so that there
are $113$ cans of soda in each box. Jerry plans to pack the sodas into cases of $12$ cans to sell. After
making as many complete cases as possible, how many sodas will Jerry have leftover?

Solution using modular arithmetic

First, we note that

$44 \equiv 8 \pmod{12}$

$113 \equiv 5 \pmod{12}$


Thus,

$44 \cdot 113 \equiv 8 \cdot 5 \equiv 40 \equiv 4 \pmod{12},$

meaning there are $4$ sodas leftover. Yeah, that was much easier.

Multiplication rule

When $a, b, c$, and $d$ are integers and $m$ is a positive integer such that

$a \equiv c \pmod{m}$

$b \equiv d \pmod{m}$

The following is always true:

$a \cdot b \equiv c \cdot d \pmod{m}$.

https://artofproblemsolving.com/wiki/index.php/Modular_arithmetic/Introduction#Addition

http://mathworld.wolfram.com/ModularArithmetic.html

You might also like