Number Theory Basics

Number theory is the study of the integers and their arithmetic structure: divisibility, primes, congruences, and Diophantine equations. Key result: every integer factors uniquely into primes (the Fundamental Theorem of Arithmetic). Applies to: cryptography, coding theory, computer science, and pure mathematics. Origins: Euclid (c. 300 BCE), systematized by Gauss in Disquisitiones Arithmeticae (1801).

Number theory begins with the deceptively simple set and asks deep questions about multiplicative and additive structure. At its foundation lie divisibility (when does one integer evenly divide another), prime numbers (the multiplicative atoms), and congruences (arithmetic "modulo "). It matters because the simplest-stated problems — e.g., "are there infinitely many twin primes?" — can resist solution for centuries, and because modular arithmetic underpins virtually all modern public-key cryptography. A surprising fact: although primes thin out among large integers, they never run out, and Euclid proved this with a one-line argument over two millennia ago.

The Core Insight

The integers form a structure where addition is simple but multiplication is profound. The primes are the indecomposable building blocks under multiplication, and the Fundamental Theorem of Arithmetic says every integer is uniquely assembled from them. Most of elementary number theory flows from two engines: the division algorithm (which controls divisibility and the GCD) and modular arithmetic (which packages divisibility relations into a clean algebraic system ).

Formal Statement

Divisibility

For integers with , we say divides , written , if there exists an integer such that:

1
⟳This is a definition; the symbol asserts existence of the integer quotient . If no such integer exists, write .

Here is a divisor (or factor) of , and is a multiple of . Basic properties: (reflexive on nonzero ); if and then (transitive); if and then for all (linearity).

Prime and Composite

An integer is prime if its only positive divisors are and . An integer that is not prime is composite. The number is a unit and is neither prime nor composite.

Division Algorithm

For any integers and with , there exist unique integers (quotient) and (remainder) such that:

2
⟳Take , the greatest integer not exceeding ; then automatically satisfies . Uniqueness follows from comparing two such representations.

Fundamental Theorem of Arithmetic

Every integer can be written as a product of primes, and this representation is unique up to the order of the factors:

3
⟳Existence is by strong induction (split any composite into smaller factors). Uniqueness rests on Euclid's Lemma: if a prime then or .

Greatest Common Divisor and Bézout's Identity

The greatest common divisor is the largest positive integer dividing both and . Bézout's identity states there exist integers with:

4
⟳ is the smallest positive value of the set ; minimality plus the division algorithm forces it to divide both and .

Two integers are coprime (relatively prime) if .

Congruence Modulo n

For a positive integer , integers and are congruent modulo , written , if:

5
⟳Equivalently, and leave the same remainder when divided by (apply the division algorithm to each).

Congruence is an equivalence relation that respects addition and multiplication, partitioning into residue classes forming the ring .

Fermat's Little Theorem

If is prime and , then:

6
⟳The nonzero residues are permuted by multiplication by ; multiplying them all together and cancelling the common factor yields .

Euler's Theorem

If , then , where Euler's totient counts integers in coprime to :

7
⟳The product runs over distinct primes dividing ; it follows from being multiplicative and . The theorem generalizes Fermat's by replacing with .

Chinese Remainder Theorem

If are pairwise coprime, the system has a unique solution modulo the product:

8
⟳Each term equals mod (since ) and vanishes mod every other (since ). Summing gives the full solution.

Why It Holds

Euclid's Theorem: Infinitely Many Primes

We show no finite list of primes is complete.

  1. Suppose, for contradiction, that there are only finitely many primes: .
  2. Form the integer .
  3. By the Fundamental Theorem of Arithmetic, has at least one prime divisor .
  4. If were one of the listed primes , then , which is impossible since no prime divides .
  5. Therefore is a prime not in our list — contradicting the assumption that the list was complete.
  6. Hence the set of primes is infinite.

Euclidean Algorithm computes the GCD

The algorithm repeatedly applies the division algorithm to find .

  1. Given , write with (equation [2]).
  2. Key lemma: . Proof: any common divisor of divides ; any common divisor of divides . The two pairs share the same divisors, hence the same greatest one.
  3. Replace by and repeat. The remainders strictly decrease: .
  4. Since a strictly decreasing sequence of nonnegative integers must terminate, some remainder reaches .
  5. When , we have , the last nonzero remainder.

Carl Friedrich Gauss | 1777–1855

Gauss called mathematics "the queen of the sciences" and number theory "the queen of mathematics." At age 24 he published Disquisitiones Arithmeticae (1801), which introduced the congruence notation , systematized modular arithmetic, proved the law of quadratic reciprocity (which he called the aureum theorema, golden theorem, and proved in multiple ways throughout his life), and laid the foundations for algebraic number theory. His insistence on rigorous proof transformed number theory from a collection of clever observations into a coherent discipline. He reputedly remarked that he discovered the prime-counting estimate as a teenager.

Building Intuition

Think of the primes as a periodic table of integers: every number is a unique molecule built from prime atoms. The exponents in the prime factorization [3] are coordinates locating each integer in an infinite-dimensional grid (one axis per prime). Divisibility then means 's coordinates are all 's, coordinate-by-coordinate — the GCD takes the minimum exponent in each slot, the LCM takes the maximum. Modular arithmetic, meanwhile, is just clock arithmetic: on a 12-hour clock, because . The Chinese Remainder Theorem says that knowing the time on several coprime clocks (mod 7, mod 11, mod 13) pins down the absolute "time" uniquely up to the product .

The sieve of Eratosthenes: composites struck out as multiples of each prime, leaving primes (gold) standing.

Integers 2–31 after sieving multiples of 2, 3, 5 2 3 5 7 11 13 17 19 23 29 31 4 6 9 15 21 25 27 Gold = prime (survives all crossings) Struck = composite (a multiple of some smaller prime)

Worked Examples

Solving a Linear Congruence with the Extended Euclidean Algorithm

Given: Solve . Step 1 — Find the inverse of 17 mod 43. Apply the Euclidean algorithm:
  • , so (an inverse exists).
Step 2 — Back-substitute (Bézout, equation [4]):
  • .

So , giving .

Step 3 — Multiply both sides by the inverse:
Check: , so . ✓

Fast Modular Exponentiation via Fermat's Little Theorem

Given: Compute . Step 1 — Apply Fermat's Little Theorem (equation [6]). Since is prime and :
Step 2 — Reduce the exponent modulo 10:
Step 3 — Evaluate the residual power:

Common Misconceptions

"The number 1 is prime." It is not. Declaring prime would destroy the uniqueness in the Fundamental Theorem of Arithmetic ([3]), since you could append any number of factors of (e.g., ). The number is a unit: it has a multiplicative inverse and is excluded from the primes precisely to preserve unique factorization. " lets you always cancel a common factor." Cancellation is only valid when the factor is coprime to the modulus. From , you may not divide by to conclude via carelessly. The correct rule: if then . The converse of Fermat's Little Theorem fails. One might hope that for some guarantees is prime. But is composite, yet . Such are called Fermat pseudoprimes (base 2). Worse, Carmichael numbers like satisfy for every coprime to , fooling the Fermat test for all bases. This is why probabilistic primality tests use the stronger Miller–Rabin criterion.

Connections

Number theory sits at a crossroads of mathematics. The ring and the group of units are the entry point to Abstract Algebra, where the GCD's Bézout identity reappears as the theory of ideals in Principal Ideal Domains. The distribution of primes, captured by the Prime Number Theorem , links elementary number theory to Complex Analysis through the Riemann zeta function. Quadratic reciprocity opens into Algebraic Number Theory, where unique factorization is recovered for ideals when it fails for elements. Congruences and the Chinese Remainder Theorem are the computational heart of Cryptography and Coding Theory.

Real-World Applications

  1. RSA public-key cryptography — security rests on the difficulty of factoring a product of two large primes; decryption uses Euler's Theorem ([7]) with exponents reduced mod .
  2. Diffie–Hellman key exchange — relies on modular exponentiation ([6]) and the hardness of the discrete logarithm in .
  3. Error-correcting codes — Reed–Solomon codes (used in CDs, DVDs, QR codes, and deep-space communication) are built over finite fields , direct generalizations of .
  4. Hash tables and hashing — modular reduction with prime distributes keys uniformly and reduces clustering.
  5. Check digits — the ISBN-10 checksum and credit-card Luhn algorithm use congruences mod 11 and mod 10 to detect transcription errors.
  6. Cryptographic random number / primality — the Miller–Rabin test (built on Fermat's Little Theorem) certifies the large primes underlying TLS/HTTPS.
  7. Computer arithmetic — the Chinese Remainder Theorem ([8]) accelerates large-integer multiplication by computing modulo several small coprime moduli in parallel.

Historical Development

  • c. 1800 BCE — Babylonian tablet Plimpton 322 lists Pythagorean triples, an early Diophantine table.
  • c. 300 BCE — Euclid's Elements (Books VII–IX) gives the Euclidean algorithm, the proof of infinitely many primes, and the link between primes and perfect numbers.
  • c. 250 CE — Diophantus of Alexandria writes Arithmetica, founding the study of integer/rational solutions of equations.
  • 1640 — Pierre de Fermat states his "Little Theorem" and his famous "Last Theorem" margin note; corresponds prolifically on number theory.
  • 1736 — Leonhard Euler proves Fermat's Little Theorem and introduces the totient function .
  • 1801 — Gauss publishes Disquisitiones Arithmeticae, introducing congruence notation and proving quadratic reciprocity.
  • 1837 — Dirichlet proves infinitely many primes in any arithmetic progression with , launching analytic number theory.
  • 1859 — Riemann's eight-page memoir connects to the zeros of , posing the Riemann Hypothesis.
  • 1896 — Hadamard and de la Vallée Poussin independently prove the Prime Number Theorem.
  • 1994 — Andrew Wiles proves Fermat's Last Theorem via modularity of elliptic curves, vindicating Fermat's 1637 claim.

Subtleties & Limits

Many of number theory's most natural questions remain open. The Riemann Hypothesis — that all nontrivial zeros of have real part — controls the finest error term in the distribution of primes and is one of the seven Millennium Prize Problems. The Twin Prime Conjecture asserts infinitely many pairs of primes; Yitang Zhang (2013) proved bounded gaps occur infinitely often, later sharpened by the Polymath project to gaps of size , but the gap of remains unproven. Goldbach's Conjecture (every even integer is a sum of two primes) is verified to enormous bounds but unproven. The abc conjecture, deciding the structure behind additive-multiplicative interactions, has a disputed claimed proof. These show that the integers, the simplest objects in mathematics, still harbor profound mysteries.

See Also

Modular Arithmetic · Prime Number Theorem · Diophantine Equations · Quadratic Reciprocity · Continued Fractions · Euler's Totient Function · Elliptic Curves

Before this

Where this leads

  • Abstract Algebra — $\mathbb{Z}/n\mathbb{Z}$, groups of units, and ideals generalize integer arithmetic.
  • Algebraic Number Theory — extends factorization to rings of algebraic integers via ideals.
  • Analytic Number Theory — uses complex analysis to study prime distribution and the zeta function.
  • Cryptography — RSA, Diffie–Hellman, and elliptic-curve schemes apply modular arithmetic directly.
  • Finite Fields — $\mathbb{F}_p = \mathbb{Z}/p\mathbb{Z}$ generalizes to all prime-power fields underpinning coding theory.