Skip to content

Applied Mathematics · Ch 1 — Numbers, Quantification and Numerical Applications

Modular Arithmetic

1.1

Modular Arithmetic

Modular arithmetic is the branch of arithmetic for integers that deals only with remainders, ignoring how many times one number divides into another. It builds on Euclid's division algorithm from earlier classes: for any dividend XX and divisor YY (with X>YX > Y, Y≠0Y \neq 0), there exist unique integers QQ (the quotient) and RR (the remainder) such that

X=Y×Q+R,0≤R<YX = Y \times Q + R, \quad 0 \le R < Y

The modulo operator, written X mod Y=RX \bmod Y = R, isolates just the remainder from this relationship — it tells you what is left over after XX is divided by YY. For instance, 29 mod 3=229 \bmod 3 = 2, since dividing 29 by 3 leaves a remainder of 2. A familiar everyday model is a 12-hour clock: 13 o'clock is displayed as 1 o'clock because 13=12×1+113 = 12 \times 1 + 1, i.e., 13 mod 12=113 \bmod 12 = 1. What matters is not how many full cycles occur, only where the count ends up — this "wrap-around" behaviour is the essence of modular arithmetic.

The values XX, YY and QQ may be positive, negative, or zero (except YY, which cannot be zero), but the remainder RR is always non-negative and strictly less than ∣Y∣|Y|. Two special cases are worth remembering: when X=YX = Y, the remainder is 00 (e.g., 3 mod 3=03 \bmod 3 = 0); and when X<YX < Y, the remainder is simply XX itself (e.g., 7 mod 13=77 \bmod 13 = 7).

Properties of the modulo operator

The modulo operator obeys four properties that make large computations manageable:

Property 1: X mod Y=(X+kY) mod YX \bmod Y = (X + kY)\bmod Y for any integer kk.

Property 2 (addition): (A+B) mod C=((A mod C)+(B mod C)) mod C(A + B)\bmod C = \big((A\bmod C) + (B\bmod C)\big)\bmod C

Property 3 (subtraction): (A−B) mod C=((A mod C)−(B mod C)) mod C(A - B)\bmod C = \big((A\bmod C) - (B\bmod C)\big)\bmod C

Property 4 (multiplication): (A×B) mod C=((A mod C)×(B mod C)) mod C(A \times B)\bmod C = \big((A\bmod C)\times(B\bmod C)\big)\bmod C

Property 1 says that adding any whole multiple of the divisor leaves the remainder unchanged. Properties 2-4 let you reduce each part of a sum, difference, or product first and only then combine them - invaluable when the raw numbers are large. For example, to find (127×137×23×50×235×15) mod 7(127\times137\times23\times50\times235\times15)\bmod 7 you replace each factor by its remainder mod 77 and multiply those small remainders instead.

Addition, subtraction and multiplication modulo mm

These properties give rise to three closed operations on remainders. For positive integers aa, bb and a modulus mm:

Addition modulo mm: a⊕mb=(a+b) mod ma \oplus_m b = (a + b)\bmod m

Subtraction modulo mm: a⊖mb=(a−b) mod ma \ominus_m b = (a - b)\bmod m

Multiplication modulo mm: a⊙mb=(a×b) mod ma \odot_m b = (a \times b)\bmod m

Each operation first combines aa and bb in the ordinary way and then keeps only the remainder on division by mm, so the result always lies in {0,1,…,m−1}\{0, 1, \ldots, m-1\}. When a subtraction turns out negative, the non-negative remainder is still taken - for instance 11⊖743=(11−43) mod 7=−32 mod 7=311 \ominus_7 43 = (11-43)\bmod 7 = -32 \bmod 7 = 3, since −32=7×(−5)+3-32 = 7\times(-5) + 3.

Where modular arithmetic is used

Because it captures anything that repeats in cycles, modular arithmetic appears far beyond the classroom: ISBN and bank-account (IBAN) numbers use modulo checksums to catch typing errors, calendars use arithmetic modulo 77 to find the day of the week for any date, and the twelve-tone musical scale rests on arithmetic modulo 1212 - the same "clock" idea that makes five hours after 1010 o'clock read as 33 o'clock.

Illustration 2. Using X=18X = 18 and Y=5Y = 5 (so that X mod Y=18 mod 5=3X \bmod Y = 18 \bmod 5 = 3), complete Table 2. For each value of kk, compute kYkY, then X+kYX + kY, and finally (X+kY) mod Y(X + kY) \bmod Y.

Since X+kY=18+5kX + kY = 18 + 5k, we tabulate:

kkkYkYX+kYX + kY(X+kY) mod Y(X + kY) \bmod Y
420383
735533
840583
−2-2−10-1083
−4-4−20-20−2-23
1260783

What the table shows: every entry in the last column equals 33, which is exactly X mod YX \bmod Y. This confirms Property 1 — adding any integer multiple kYkY of the divisor to XX leaves the remainder unchanged: X mod Y=(X+kY) mod YX \bmod Y = (X + kY) \bmod Y. (For the negative rows note that remainders stay non-negative, e.g. −2=5×(−1)+3-2 = 5\times(-1) + 3, so −2 mod 5=3-2 \bmod 5 = 3.)


Illustration 3. Complete the table below, where AA, BB and CC are positive integers, and verify the addition property (A+B) mod C=(A mod C+B mod C) mod C(A + B) \bmod C = (A \bmod C + B \bmod C) \bmod C. Here Z=A mod C+B mod CZ = A \bmod C + B \bmod C.

AABBCC(A+B) mod C(A+B) \bmod CA mod CA \bmod CB mod CB \bmod CZZZ mod CZ \bmod C
1725442 mod 4=242 \bmod 4 = 21122
84379121 mod 9=4121 \bmod 9 = 43144
39341773 mod 17=573 \bmod 17 = 55055
1712453416 mod 3=2416 \bmod 3 = 20222

In every row the fourth column (A+B) mod C(A+B)\bmod C matches the last column Z mod CZ \bmod C, verifying the addition property.


Illustration 4. Complete the table below, where AA, BB and CC are positive integers, and verify the subtraction property (A−B) mod C=(A mod C−B mod C) mod C(A - B) \bmod C = (A \bmod C - B \bmod C) \bmod C. Here Z=A mod C−B mod CZ = A \bmod C - B \bmod C.

AABBCC(A−B) mod C(A-B) \bmod CA mod CA \bmod CB mod CB \bmod CZZZ mod CZ \bmod C
3725412 mod 4=012 \bmod 4 = 01100
8437947 mod 9=247 \bmod 9 = 23122
3934175 mod 17=55 \bmod 17 = 55055
245171374 mod 3=274 \bmod 3 = 22022
Figure 1.1A 12-hour clock face illustrating modulo 12 arithmetic, where 13 o'clock shows as 1 because 13 mod 12 = 1
Fig. 1.1 — A 12-hour clock face illustrating modulo 12 arithmetic, where 13 o'clock shows as 1 because 13 mod 12 = 1

Drawn by us to help you understand the concept clearly, and verified to make sure it's accurate. For exams, practice from your NCERT textbook's own diagram.

On a 12-hour clock, hours repeat every 12 — clock arithmetic is arithmet …