Number Theory

⚡ Key Takeaways

Number Theory is the study of the integers Z\mathbb{Z} and their arithmetic structure — divisibility, primes, congruences, and Diophantine equations. Key result in words: every integer greater than 1 factors uniquely into primes, and the distribution and behavior of those primes underlie nearly all of arithmetic. Where it applies: cryptography, coding theory, computer algebra, and pure mathematics. Who/when: from Euclid (~300 BCE) and Diophantus through Fermat, Euler, Gauss (Disquisitiones Arithmeticae, 1801), to modern analytic and algebraic number theory.

💡 The Core Insight

The integers are not a featureless set: they carry a rigid multiplicative skeleton built from the primes, the indivisible atoms of arithmetic. Two engines drive the whole subject. First, unique factorization (the Fundamental Theorem of Arithmetic) lets us reduce questions about all integers to questions about primes. Second, congruence (working modulo nn) partitions the infinite integers into a finite arithmetic system Z/nZ\mathbb{Z}/n\mathbb{Z}, where addition, multiplication, and even "square roots" can be analyzed exhaustively. Almost every classical theorem — Fermat's little theorem, Euler's theorem, the Chinese Remainder Theorem, quadratic reciprocity — is a statement about the structure of these finite systems and how the primes thread through them.

Formal Statement

DefinitionDivisibility and Primes

For integers a,ba, b with a≠0a \neq 0, we say aa divides bb (written a∣ba \mid b) if there exists an integer kk with b=akb = ak. A prime p>1p > 1 is an integer whose only positive divisors are 11 and pp. An integer n>1n > 1 that is not prime is composite. The greatest common divisor gcd⁡(a,b)\gcd(a,b) is the largest positive integer dividing both aa and bb; if gcd⁡(a,b)=1\gcd(a,b)=1, aa and bb are coprime.

TheoremFundamental Theorem of Arithmetic

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

1
n=p1a1p2a2⋯pkak,p1<p2<⋯<pk, ai≥1.\quad n = p_1^{a_1} p_2^{a_2} \cdots p_k^{a_k}, \qquad p_1 < p_2 < \cdots < p_k,\ a_i \ge 1.

Derivation hint: existence by strong induction (split any composite into smaller factors); uniqueness from Euclid's Lemma — if p∣abp \mid ab then p∣ap \mid a or p∣bp \mid b.

DefinitionCongruence

For a positive integer nn (the modulus), integers aa and bb are congruent modulo nn, written a≡b(modn)a \equiv b \pmod{n}, if n∣(a−b)n \mid (a - b). This is an equivalence relation partitioning Z\mathbb{Z} into nn residue classes, forming the ring Z/nZ\mathbb{Z}/n\mathbb{Z}.

2
a≡b(modn)  ⟺  a−b=kn for some k∈Z.\quad a \equiv b \pmod{n} \iff a - b = kn \text{ for some } k \in \mathbb{Z}.

Derivation hint: directly from the definition of divisibility applied to the difference a−ba-b.

TheoremBézout's Identity

For integers a,ba, b not both zero, there exist integers x,yx, y such that

3
ax+by=gcd⁡(a,b).\quad ax + by = \gcd(a,b).

Derivation hint: gcd⁡(a,b)\gcd(a,b) is the smallest positive value of ax+byax+by; run the Extended Euclidean Algorithm to produce explicit x,yx,y.

TheoremFermat's Little Theorem & Euler's Theorem

If pp is prime and p∤ap \nmid a, then ap−1≡1(modp)a^{p-1} \equiv 1 \pmod{p}. More generally, if gcd⁡(a,n)=1\gcd(a,n)=1,

4
aφ(n)≡1(modn),\quad a^{\varphi(n)} \equiv 1 \pmod{n},

where φ(n)\varphi(n) is Euler's totient — the count of integers in {1,…,n}\{1,\dots,n\} coprime to nn. Derivation hint: the units mod nn form a group of order φ(n)\varphi(n); apply Lagrange's theorem (order of an element divides group order).

TheoremQuadratic Reciprocity

For distinct odd primes p,qp, q, with the Legendre symbol (ap)=±1\left(\tfrac{a}{p}\right) = \pm 1 recording whether aa is a nonzero square mod pp,

5
(pq)(qp)=(−1)p−12⋅q−12.\quad \left(\frac{p}{q}\right)\left(\frac{q}{p}\right) = (-1)^{\frac{p-1}{2}\cdot\frac{q-1}{2}}.

Derivation hint: Gauss's lemma counts sign changes of multiples of aa in a half-residue system; Eisenstein's lattice-point argument geometrizes the exponent.

TheoremPrime Number Theorem

Letting π(x)\pi(x) count primes ≤x\le x,

6
π(x)∼xln⁡x,equivalentlylim⁡x→∞π(x)ln⁡xx=1.\quad \pi(x) \sim \frac{x}{\ln x}, \qquad \text{equivalently}\quad \lim_{x\to\infty} \frac{\pi(x)\ln x}{x} = 1.

Derivation hint: relate π(x)\pi(x) to the Riemann zeta function via the Euler product; the key analytic input is that ζ(s)\zeta(s) has no zeros on the line ℜ(s)=1\Re(s)=1.

Why It Holds / Derivation

ProofUniqueness in the Fundamental Theorem of Arithmetic

We prove uniqueness, given existence. 1. Euclid's Lemma. Suppose pp is prime and p∣abp \mid ab. If p∤ap \nmid a, then gcd⁡(p,a)=1\gcd(p,a)=1 (since pp's only divisors are 1,p1,p). By Bézout (eq. [3]) there are integers x,yx,y with px+ay=1px + ay = 1. 2. Multiply by bb: pbx+aby=bpbx + aby = b. Since p∣pbxp \mid pbx and p∣abp \mid ab (so p∣abyp \mid aby), pp divides the left side, hence p∣bp \mid b. 3. Extending to products. By induction, if p∣q1q2⋯qmp \mid q_1 q_2 \cdots q_m, then p∣qjp \mid q_j for some jj. 4. Uniqueness. Suppose n=p1⋯pr=q1⋯qsn = p_1\cdots p_r = q_1 \cdots q_s are two prime factorizations. Then p1∣q1⋯qsp_1 \mid q_1\cdots q_s, so by step 3 p1=qjp_1 = q_j for some jj (both prime). Cancel them. 5. Repeat. Each pip_i matches a unique qjq_j and vice versa, so r=sr = s and the multisets of primes coincide. ■\blacksquare

∎
ProofEuler's Theorem via Group Theory

1. Let U(n)=(Z/nZ)×U(n) = (\mathbb{Z}/n\mathbb{Z})^\times be the set of residue classes coprime to nn. It is a group under multiplication mod nn with ∣U(n)∣=φ(n)|U(n)| = \varphi(n). 2. Closure holds because gcd⁡(a,n)=gcd⁡(b,n)=1⇒gcd⁡(ab,n)=1\gcd(a,n)=\gcd(b,n)=1 \Rightarrow \gcd(ab,n)=1; inverses exist by Bézout (eq. [3]). 3. By Lagrange's Theorem, the order of any element a∈U(n)a \in U(n) divides ∣U(n)∣=φ(n)|U(n)| = \varphi(n). 4. Hence aφ(n)=(aord(a))k≡1(modn)a^{\varphi(n)} = (a^{\text{ord}(a)})^{k} \equiv 1 \pmod n. Taking n=pn=p gives φ(p)=p−1\varphi(p)=p-1, recovering Fermat's Little Theorem. ■\blacksquare

∎
mathematician · Carl Friedrich Gauss | 1777–1855

Gauss called number theory "the Queen of Mathematics." At age 24 he published Disquisitiones Arithmeticae (1801), which systematized congruences, introduced the now-standard ≡\equiv notation, and gave the first complete proof of quadratic reciprocity — a theorem he proved in at least eight distinct ways over his life, calling it the theorema aureum (golden theorem). He also conjectured the Prime Number Theorem as a teenager by examining prime-counting tables, anticipating the logarithmic integral Li(x)\mathrm{Li}(x) as a far better approximation to π(x)\pi(x) than x/ln⁡xx/\ln x. His work on Gaussian integers Z[i]\mathbb{Z}[i] launched algebraic number theory.

Building Intuition

🧠 Intuition

Think of the primes as a basis for the integers under multiplication — not a vector-space basis, but an analogous "independent generating set." Every integer is a unique "word" spelled in prime letters (eq. [1]). Divisibility becomes a coordinate-wise comparison: a∣ba \mid b iff every prime appears in aa to a lower-or-equal power than in bb. This is why gcd⁡\gcd and lcm\mathrm{lcm} are just the coordinate-wise min and max of exponents. Congruence is the act of folding the number line into a circle of circumference nn. Once folded, only finitely many points remain, so any question — "is there a solution?", "what are all the squares?" — becomes a finite check. The miracle of number theory is that statements about the infinite integers (eq. [4], [5]) reduce to finite combinatorics in these clocks, while the distribution of primes (eq. [6]) reaches back out to the infinite via complex analysis.

Figure
The number line folded modulo 7 into a residue clock, with quadratic residues highlighted
Z folded mod 7 — residue classes 0..6 0 1 2 3 4 5 6 7 = 14 = 21 = ... all map to 0 gold ring = quadratic residues {1,2,4} mod 7

Worked Examples

ExampleSolving a Linear Congruence with the Extended Euclidean Algorithm

Given: Solve 17x≡5(mod43)17x \equiv 5 \pmod{43}.

Step 1 — Find gcd⁡(17,43)\gcd(17,43) and Bézout coefficients.

  • 43=2⋅17+943 = 2\cdot 17 + 9
  • 17=1⋅9+817 = 1\cdot 9 + 8
  • 9=1⋅8+19 = 1\cdot 8 + 1
  • 8=8⋅1+08 = 8\cdot 1 + 0, so gcd⁡=1\gcd = 1 (the congruence is solvable).

Step 2 — Back-substitute for 1=17x+43y1 = 17x + 43y. 1=9−8=9−(17−9)=2⋅9−17=2(43−2⋅17)−17=2⋅43−5⋅171 = 9 - 8 = 9 - (17-9) = 2\cdot 9 - 17 = 2(43 - 2\cdot17) - 17 = 2\cdot43 - 5\cdot17. So −5⋅17≡1(mod43)-5\cdot17 \equiv 1 \pmod{43}, giving 17−1≡−5≡38(mod43)17^{-1} \equiv -5 \equiv 38 \pmod{43}.

Step 3 — Multiply both sides by the inverse. x≡38⋅5=190(mod43)x \equiv 38 \cdot 5 = 190 \pmod{43}. Since 190=4⋅43+18190 = 4\cdot43 + 18:

x≡18(mod43)\boxed{x \equiv 18 \pmod{43}}

Check: 17⋅18=306=7⋅43+5≡517\cdot 18 = 306 = 7\cdot43 + 5 \equiv 5. ✓

ExampleUsing the Chinese Remainder Theorem

Given: Find xx with x≡2(mod3)x \equiv 2 \pmod 3, x≡3(mod5)x \equiv 3 \pmod 5, x≡2(mod7)x \equiv 2 \pmod 7.

Step 1 — Modulus product. N=3⋅5⋅7=105N = 3\cdot5\cdot7 = 105. Partial products: N1=35, N2=21, N3=15N_1 = 35,\ N_2 = 21,\ N_3 = 15.

Step 2 — Inverses.

  • 35≡2(mod3)35 \equiv 2 \pmod 3, need 2y1≡12y_1\equiv1: y1=2y_1 = 2.
  • 21≡1(mod5)21 \equiv 1 \pmod 5, so y2=1y_2 = 1.
  • 15≡1(mod7)15 \equiv 1 \pmod 7, so y3=1y_3 = 1.

Step 3 — Combine. x≡2⋅35⋅2+3⋅21⋅1+2⋅15⋅1=140+63+30=233(mod105)x \equiv 2\cdot35\cdot2 + 3\cdot21\cdot1 + 2\cdot15\cdot1 = 140 + 63 + 30 = 233 \pmod{105}. 233=2⋅105+23233 = 2\cdot105 + 23:

x≡23(mod105)\boxed{x \equiv 23 \pmod{105}}

Check: 23=7⋅3+223 = 7\cdot3+2 ✓, 23=4⋅5+323 = 4\cdot5+3 ✓, 23=3⋅7+223 = 3\cdot7+2 ✓.

Common Misconceptions

⚠️ Common mistake

"Every ring of integers has unique factorization." False. In Z[−5]\mathbb{Z}[\sqrt{-5}],

6=2⋅3=(1+−5)(1−−5),6 = 2\cdot 3 = (1+\sqrt{-5})(1-\sqrt{-5}),

two genuinely different factorizations into irreducibles. The Fundamental Theorem of Arithmetic is a special property of Z\mathbb{Z} (and of certain rings called UFDs). Recovering unique factorization in general required Dedekind's theory of ideals — and that historical failure is precisely why algebraic number theory exists.

"Fermat's Little Theorem characterizes primes." Not quite. There are Carmichael numbers (e.g., 561=3⋅11⋅17561 = 3\cdot11\cdot17) that are composite yet satisfy an−1≡1(modn)a^{n-1}\equiv 1 \pmod n for all aa coprime to nn, fooling naive primality tests.

Counterexample

Claim: "If pp is prime then 2p−12^p - 1 is prime (Mersenne primes)." Refutation: p=11p = 11 is prime, but 211−1=2047=23⋅892^{11} - 1 = 2047 = 23 \cdot 89 is composite. Primality of the exponent is necessary (if nn is composite, 2n−12^n-1 is composite) but not sufficient. Whether infinitely many Mersenne primes exist remains open.

Connections

connection

Number theory sits at a crossroads. Modular arithmetic is the entry point to Abstract Algebra: Z/nZ\mathbb{Z}/n\mathbb{Z} is the canonical example of a ring, and U(n)U(n) a finite abelian group, so Group Theory (Lagrange's theorem) directly yields Euler's theorem (eq. [4]). The leap to analytic number theory ties the integers to Complex Analysis through the Riemann zeta function and the Euler product, which is how the Prime Number Theorem (eq. [6]) is proved. The failure of unique factorization links to Ring Theory and Dedekind domains, while Galois Theory explains quadratic reciprocity (eq. [5]) as a shadow of class field theory. Finally, the geometry of solutions to Diophantine equations connects to Elliptic Curves and Algebraic Geometry.

Real-World Applications

🔬 Where this appears

Historical Development

⏳ History
- ~300 BCE — Euclid. Elements Books VII–IX: the Euclidean algorithm, Euclid's Lemma, infinitude of primes, and perfect numbers.
- ~250 CE — Diophantus. Arithmetica studies rational/integer solutions of polynomial equations, the namesake of Diophantine analysis.
- 1640 — Fermat. States his "little theorem" and Fermat's Last Theorem in marginal notes; pioneers the method of infinite descent.
- 1736–1770 — Euler. Proves Fermat's Little Theorem, introduces the totient φ\varphi, the zeta function as an Euler product, and proves n=4n=4 and n=3n=3 cases of FLT.
- 1801 — Gauss. Disquisitiones Arithmeticae: congruence notation, quadratic reciprocity (eq. [5]), Gaussian integers, composition of forms.
- 1837 — Dirichlet. Proves infinitely many primes in any arithmetic progression a,a+d,a+2d,…a, a+d, a+2d,\dots with gcd⁡(a,d)=1\gcd(a,d)=1, founding analytic number theory via LL-functions.
- 1859 — Riemann. On the Number of Primes Less Than a Given Magnitude links π(x)\pi(x) to zeros of ζ(s)\zeta(s); states the Riemann Hypothesis.
- 1896 — Hadamard & de la Vallée Poussin. Independently prove the Prime Number Theorem (eq. [6]).
- 1994 — Wiles (with Taylor). Proves Fermat's Last Theorem via modularity of elliptic curves, capping 350 years of effort and unifying vast areas.

Subtleties & Limits

open-problem

Number theory is famous for elementary-sounding questions that resist all attack.

  • Riemann Hypothesis: all nontrivial zeros of ζ(s)\zeta(s) have ℜ(s)=12\Re(s) = \tfrac12. It would sharpen the error term in the Prime Number Theorem (eq. [6]) to π(x)=Li(x)+O(xln⁡x)\pi(x) = \mathrm{Li}(x) + O(\sqrt{x}\ln x). (Clay Millennium Prize.)
  • Goldbach's Conjecture: every even integer >2> 2 is a sum of two primes. Verified past 4×10184\times10^{18}, unproven.
  • Twin Prime Conjecture: infinitely many primes pp with p+2p+2 prime. Zhang (2013) proved bounded gaps exist; the gap is now ≤246\le 246 (Polymath/Maynard), not yet 22.
  • abc Conjecture: a deep inequality relating prime factors of a,b,a+ba, b, a+b; would imply many results including (asymptotic) FLT. Mochizuki's claimed proof remains disputed.
  • Infinitude of Mersenne primes and existence of odd perfect numbers — both open since antiquity.

See Also

Abstract Algebra · Group Theory · Ring Theory · Complex Analysis · Galois Theory · Cryptography · Finite Fields · Elliptic Curves · Algebraic Number Theory · Analytic Number Theory