Folioby Interconnected
Log InSign Up

What does it mean to "divide evenly"? Why number theory begins with mod

The modular reduction map is a projection that deliberately discards information. Clocks, days of the week, and the competitive-programming modulus 10^9+7 all share the same algebraic structure. From the definition of divisibility through congruences to the ring Z/nZ, we uncover the reason number theory starts where it does.

FO
Folio Official
March 1, 2026

Open any number theory textbook and, within the first few pages, you will encounter the notation a≡b(modn). What the textbook rarely pauses to explain is why number theory begins with remainders. In this article we shall see that the mod operation is a deliberate act of forgetting – a projection that discards the quotient and retains only the remainder – and that the arithmetic of clocks, calendars, and competitive-programming problems all rest on exactly the same algebraic foundation.

1 Divisibility: the starting point

Definition 1 (Divisibility).
For integers a and b, we say that adividesb, and write a∣b, if there exists an integer q such that b=qa.
Example 2.
3∣12 (since 12=4×3), but 3∤7.

Divisibility is deceptively simple, yet it carries powerful consequences.

Theorem 3 (Basic properties of divisibility).
For integers a,b,c:
  • If a∣b and a∣c, then a∣(b+c) and a∣(b−c).

  • If a∣b, then a∣kb for every integer k.

  • If a∣b and b∣c, then a∣c (transitivity).

Each of these is straightforward to prove, but together they express a single essential fact: the divisibility relation is preserved under linear combinations.

2 The Division Theorem: existence and uniqueness of remainders

Theorem 4 (Division Theorem).
For any integer a and positive integer n, there exist unique integers q (quotient) and r (remainder) such that
a=qn+r,0≤r<n.
Proof.
For existence, consider the set S={a−kn∣k∈Z,a−kn≥0} and take r to be its smallest element. If r≥n, then r−n≥0 and r−n<r, contradicting the minimality of r. For uniqueness, suppose a=q1​n+r1​=q2​n+r2​. Then ∣r1​−r2​∣=∣q2​−q1​∣n, and since 0≤∣r1​−r2​∣<n, we conclude r1​=r2​. □

This theorem guarantees that the remainder r is well-defined – a fact on which the entire theory of congruences depends.

3 Congruences: focusing on remainders

Definition 5 (Congruence).
For integers a,b and a positive integer n, we say that a is congruent to b modulo n, and write
a≡b(modn),
if n∣(a−b).
Remark 6.
The condition a≡b(modn) is equivalent to saying that a and b leave the same remainder when divided by n. In other words, a congruence retains only the remainder and discards everything else.

The power of congruences lies in their compatibility with arithmetic.

Theorem 7 (Arithmetic of congruences).
If a≡a′(modn) and b≡b′(modn), then:
  • a+b≡a′+b′(modn)

  • a−b≡a′−b′(modn)

  • ab≡a′b′(modn)

Proof.
Write n∣(a−a′) and n∣(b−b′). For addition, (a+b)−(a′+b′)=(a−a′)+(b−b′), and the claim follows. For multiplication, decompose ab−a′b′=a(b−b′)+b′(a−a′); each term is divisible by n. □

4 Everyday mod: clocks, calendars, and109+7

Modular arithmetic pervades daily life.

Example 8 (Clocks).
At 10 a.m., five hours later it is 3 p.m.: 10+5=15≡3(mod12). A clock face is the world of Z/12Z.
Example 9 (Days of the week).
If today is Wednesday (call it 3), what day is it ten days from now? 3+10=13≡6(mod7)– Saturday. The weekly cycle lives in Z/7Z.
Example 10 (The modulus 109+7 in competitive programming).
Competitive programming contests (AtCoder, Codeforces, and others) routinely ask for answers modulo 109+7. Why this particular number?
  • 109+7 is a prime. Working modulo a prime guarantees that every nonzero element has a multiplicative inverse, so division is possible (a point we shall develop in a later article).

  • 109+7<230, so the product of two residues satisfies (109+7)2<262 and fits in a 64-bit integer.

5 Mod as information projection

Remark 11.
The essence of the mod operation is information loss by design. The map a↦amodn is a surjection from Z onto {0,1,…,n−1}. It throws away the quotient q and retains only the remainder r.

What is remarkable is that, despite discarding information, this map preserves both addition and multiplication. In the language of algebra, the natural map Z→Z/nZ is a ring homomorphism.

6 A first look at the ringZ/nZ

Equipping the set of remainders {0,1,…,n−1} with addition and multiplication gives the algebraic structure denoted Z/nZ.

Definition 12 (Z/nZ).
Z/nZ={0ˉ,1ˉ,…,n−1​}, with operations aˉ+bˉ=a+b​ and aˉ⋅bˉ=a⋅b, is called the residue ring modulo n.
Remark 13.
When n is prime, Z/nZ is a field: every nonzero element has a multiplicative inverse, and division is available. This is the algebraic reason why the competitive-programming modulus 109+7 is chosen to be prime.

7 Takeaway

  • Divisibility a∣b is the most fundamental relation in number theory.

  • Congruences formalize the idea of "looking only at remainders," and they are compatible with addition and multiplication.

  • The mod operation is a projection that deliberately discards information. Clocks, days of the week, and the modulus 109+7 all share the same underlying structure.

  • Z/nZ endows the world of remainders with an algebraic structure; when n is prime, that structure is a field.

In the next article, we turn to the computation of greatest common divisors – the Euclidean algorithm – and ask why its simple recursion always finds the largest common factor.

Number TheoryMathematicsBetween the Lines
FO
Folio Official

Mathematics "between the lines" — exploring the intuition textbooks leave out, written in LaTeX on Folio.

1 followers·107 articles
Number Theory — Between the LinesPart 1 of 8
No previous article
Next
Why the Euclidean algorithm finds the greatest common divisor: from subtraction to division

Share your expertise with the world

Write articles with LaTeX support, build your audience, and earn from your knowledge.

Start Writing — It's Free

More from Folio Official

Folio Official·March 1, 2026

Why primes are the atoms of the integers: what the Fundamental Theorem of Arithmetic really says

Unique prime factorization is not as obvious as it seems. Through a counterexample in Z[sqrt(-5)], we witness uniqueness break down, then prove both the existence and uniqueness parts of the Fundamental Theorem, and survey the Sieve of Eratosthenes and the linear sieve.

Number TheoryMathematicsBetween the Lines
Folio Official·March 1, 2026

The Chinese Remainder Theorem: why simultaneous congruences can be merged

We view CRT as the number-theoretic incarnation of divide-and-conquer, prove the ring isomorphism Z/mnZ = Z/mZ x Z/nZ, and show how Garner's algorithm avoids overflow in practice.

Number TheoryMathematicsBetween the Lines
Folio Official·March 1, 2026

Why the Euclidean algorithm finds the greatest common divisor: from subtraction to division

The recursion gcd(a,b) = gcd(b, a mod b) hides an invariant: the set of common divisors never changes. Starting from a naive subtraction-based method and upgrading to division, we derive Bezout's identity, the extended Euclidean algorithm, and modular inverses.

Number TheoryMathematicsBetween the Lines
Folio Official·March 1, 2026

Number theory meets cryptography: why RSA works and what makes it secure

Every theorem in this series -- Fermat, Euler, the extended Euclidean algorithm, CRT -- corresponds to a component of the RSA cryptosystem. We trace each connection, work through a concrete example, and discuss the factoring barrier that underpins RSA's security.

Number TheoryMathematicsBetween the Lines