Folioby Interconnected
Log InSign Up

Primes and the Fundamental Theorem of Arithmetic — The Atomic Decomposition of Integers

We define prime numbers and establish their basic properties, including Euclid's proof of the infinitude of primes. We then give a rigorous proof of the fundamental theorem of arithmetic (existence and uniqueness of prime factorization), and discuss the sieve of Eratosthenes and the Miller--Rabin primality test.

FO
Folio Official
March 1, 2026

1 Definition and Basic Properties of Primes

Definition 1 (Prime number).
An integer p≥2 is called a prime if its only positive divisors are 1 and p itself. An integer n≥2 that is not prime is called composite.
Lemma 2 (Euclid's lemma).
If p is prime and p∣ab, then p∣a or p∣b.
Proof.
Suppose p∤a. Since p is prime, gcd(p,a)=1. By Béx,y with px+ay=1. Multiplying both sides by b gives pbx+aby=b. Now p∣pb and p∣ab, so p∣(pbx+aby)=p∣b. □
Corollary 3.
If p is prime and p∣a1​a2​⋯an​, then p∣ai​ for some i.

2 The Infinitude of Primes

Theorem 4 (Euclid).
There are infinitely many primes.
Proof.
Suppose, for contradiction, that p1​,p2​,…,pn​ is a complete list of all primes. Set N=p1​p2​⋯pn​+1. Since N≥2, it has at least one prime factor p. This p must equal some pi​. But then p∣N and p∣p1​⋯pn​, so p∣(N−p1​⋯pn​)=p∣1. This contradicts p≥2. □

3 The Fundamental Theorem of Arithmetic

Theorem 5 (Fundamental theorem of arithmetic).
Every integer n≥2 can be written as a product of primes (existence). Moreover, this representation is unique up to the ordering of the factors (uniqueness):
n=p1e1​​p2e2​​⋯pkek​​(p1​<p2​<⋯<pk​,ei​≥1).
Proof.
Existence. We proceed by strong induction on n. The base case n=2 holds since 2 is prime. For n>2: if n is prime, we are done. If n is composite, write n=ab with 1<a,b<n. By the inductive hypothesis, both a and b are products of primes, so n is as well.

Uniqueness. Suppose n=p1​p2​⋯ps​=q1​q2​⋯qt​ with p1​≤⋯≤ps​ and q1​≤⋯≤qt​. We argue by induction on s. If s=1, then n=p1​ is prime, forcing t=1 and q1​=p1​. For s≥2: since p1​∣q1​q2​⋯qt​, Euclid's lemma gives p1​∣qj​ for some j. Since qj​ is also prime, p1​=qj​. Dividing both sides by p1​ yields p2​⋯ps​=q1​⋯qj−1​qj+1​⋯qt​. By the inductive hypothesis, s−1=t−1 and the remaining prime factors agree up to reordering. □

4 The Sieve of Eratosthenes

Remark 6.
The sieve of Eratosthenes is a classical method for listing all primes up to n. One writes down the integers from 2 to n and, for each prime p with p2≤n, strikes out the multiples p2,p2+p,…. The surviving numbers are precisely the primes. The time complexity is O(nloglogn).
Theorem 7.
Every composite number n has a prime factor at most n​.
Proof.
Write n=ab with 1<a≤b<n. Then a2≤ab=n, so a≤n​. Any prime factor of a is at most a≤n​. □

5 The Miller–Rabin Primality Test

Definition 8.
For an odd integer n>2, write n−1=2sd with d odd. An integer a with gcd(a,n)=1 is called a strong probable prime witness for n if ad≡1(modn) or a2rd≡−1(modn) for some r∈{0,1,…,s−1}.
Theorem 9.
If n is prime, then every a with gcd(a,n)=1 is a strong probable prime witness. If n is composite, then at most 1/4 of the integers a with 1≤a≤n−1 are strong probable prime witnesses.
Remark 10.
Based on this theorem, testing k randomly chosen bases a yields a probability of at most 4−k that a composite number passes as prime. With k=20, this probability falls below 10−12, which is more than sufficient for practical purposes.
Number TheoryAlgebraTextbookPrimesFundamental Theorem of Arithmetic
FO
Folio Official

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

1 followers·107 articles
Number Theory TextbookPart 4 of 13
Previous
The Greatest Common Divisor and the Euclidean Algorithm — Algebraic Foundations of an Algorithm
Next
Applications of Congruences and the Group of Units — The Structure of $(\mathbb{Z}/n\mathbb{Z})^*$

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

Introduction to Algebraic Integers — Extending the Notion of Integer

Using the Gaussian integers Z[i] and the Eisenstein integers Z[omega] as concrete examples, we introduce rings of algebraic integers. We demonstrate the failure of unique factorization in Z[sqrt(-5)] and show how ideals and prime ideal factorization restore uniqueness. We define the class number and discuss its significance.

Number TheoryAlgebraTextbook
2
Folio Official·March 1, 2026

Arithmetic Functions and Multiplicative Functions — Functions on the Integers

We systematically define the principal multiplicative functions (phi, sigma, mu, d), develop the ring structure of Dirichlet convolution, and give a rigorous proof of the Moebius inversion formula. We also clarify the connection to the inclusion-exclusion principle.

Number TheoryAlgebraTextbook
Folio Official·March 1, 2026

Chebyshev's Estimates: 0.92 x/ln x < π(x) < 1.11 x/ln x and the Prime Number Theorem

Chebyshev proved that 0.92 x/ln x < π(x) < 1.11 x/ln x for sufficiently large x. This article gives a complete proof via binomial coefficients and the Chebyshev functions θ(x) and ψ(x), then traces the path to the prime number theorem π(x) ~ x/ln x.

Number TheoryAlgebraTextbook
Folio Official·March 1, 2026

Continued Fractions and Diophantine Approximation — The Theory of Rational Approximation

We define finite and infinite continued fractions, prove convergence, and rigorously establish the properties of convergents. We develop the theory of best rational approximations, solve the Pell equation x^2 - Dy^2 = 1 via continued fractions, and discuss the Stern--Brocot tree.

Number TheoryAlgebraTextbook