Primes and Composite Numbers
What is the smallest set of building blocks? From these, every whole number can be assembled by multiplication alone. This question, ancient and still generative, is the doorway to the theory of primes. A prime number is a positive integer greater than 1. It has exactly two positive divisors. Every other integer greater than 1 is composite, meaning it breaks apart into smaller factors. This distinction looks almost too simple to matter. Yet it is the seed from which the entire multiplicative structure of the integers grows. The idea matters because multiplication, unlike addition, has no obvious "unit of measure." Addition is generated by the single element 1. Multiplication of integers, however, is generated by infinitely many elements — the primes. None of these reduces further. Understanding which numbers are prime matters greatly. So does knowing how to detect primality by trial division. And knowing how every integer decomposes into primes matters too. Together these give us the first rigorous foothold on deeper questions. How many primes are there? How are they distributed? Can every number be built uniquely from them? The big picture is this: primes play the role for multiplication that atoms play for matter. They are like the number 1 for addition — except there are infinitely many types of "atom." Discovering their laws occupies number theory from its first page to its research frontier. These laws include how many primes exist, how they are spaced, and how factorization behaves. This article sits at the very foundation. It fixes the definitions and establishes the mechanical tool of trial division for testing primality. It also proves that every integer greater than 1 admits at least one decomposition into primes. This is the existence half of what will later become the Fundamental Theorem of Arithmetic. What this article delivers: precise definitions of prime and composite numbers, a fully justified trial-division algorithm. This includes the proof that checking divisors up to suffices. It also offers a rigorous proof by strong induction. This proof shows that every integer greater than 1 factors into primes. There are worked examples on genuinely awkward numbers. A counterexample shows why the hypothesis cannot be dropped. Finally, there is a forward glance toward uniqueness of factorization and the Infinitude of Primes.
- A prime has exactly two positive divisors: and itself; anything else greater than is composite.
- The number is neither prime nor composite — it is a special case, the multiplicative unit.
- Trial division tests primality by checking candidate divisors only up to , not up to .
- Every integer has at least one prime divisor — this is the engine behind factorization.
- Strong induction proves every integer is a product of (one or more) primes — existence of factorization.
- Key idea: primes are the irreducible multiplicative atoms of , and every integer decomposes into them.
Where this lives today
Trial division and the elementary structure of primes are not merely historical curiosities; they underlie practical and theoretical machinery across mathematics and computing. In cryptography, the RSA public-key system relies on the practical difficulty of factoring large composite numbers (the product of two large primes) even though existence of a factorization is guaranteed by the theorem above — the gap between "a factorization exists" and "a factorization is easy to find" is precisely what protects encrypted data. In computer science, trial division (and its refinements, such as the sieve methods and probabilistic tests like Miller–Rabin) forms the baseline algorithm against which faster primality tests and factoring algorithms are measured. In pure number theory, the existence-of-factorization result proved here is the first half of the Fundamental Theorem of Arithmetic, whose uniqueness half underlies virtually all further arithmetic (computing greatest common divisors via prime exponents, defining arithmetic functions like and , and studying Diophantine equations). In statistics and random number generation, prime moduli are chosen for linear congruential generators because primality guarantees useful algebraic structure (Modular Arithmetic modulo a prime forms a field). Finally, the question this article opens the door to — how many primes are there, and how are they spaced? — leads directly to Euclid's proof of the Infinitude of Primes and, further out, to the Prime Number Theorem and the Riemann Hypothesis.
Ask the tutor: How does Euclid's Lemma turn this existence proof into a full proof of unique factorization?
Let be an integer with . We say is prime if its only positive divisors are and itself. Equivalently, is prime if whenever with positive integers, one of equals (and the other equals ). We say is composite if it is not prime, i.e. if there exist integers with , , and . The integer is declared to be neither prime nor composite (it has only one positive divisor, namely itself, so it fits neither definition). By convention, primality and compositeness are defined only for integers strictly greater than .
Intuition
Think of the positive integers greater than as objects sitting on an assembly line, and multiplication as the operation of gluing two smaller objects together. Some objects — the primes — cannot be produced by gluing two smaller pieces (other than the trivial gluing with the identity factor ). Every other object, the composites, can be pulled apart into at least two nontrivial pieces. If those pieces are themselves composite, pull them apart again; since the pieces strictly shrink and are bounded below by , this process must terminate, and it terminates exactly when every remaining piece is prime. That intuitive "pulling apart until stuck" process is precisely the content of the proof below, made rigorous through strong induction. Trial division formalizes the search for a nontrivial divisor. To test whether is prime, we do not need to check every integer from to : if with , then and cannot both exceed , since their product would then exceed . So it suffices to search for a divisor no larger than . This single inequality is what makes primality testing by hand feasible even for numbers in the hundreds.
Central results
Let be an integer with , and let be the smallest divisor of satisfying . Then is prime.
Such a exists because the set is nonempty (it contains itself, since and ) and is a set of positive integers, hence has a least element by the Well-Ordering Principle. Suppose, for contradiction, that is not prime. Since and is not prime, is composite, so by definition there exist integers with
Since and , divisibility is transitive (if and then and for integers , so , giving ), hence . But satisfies , so is a divisor of that is greater than and strictly smaller than . This contradicts the minimality of among divisors of exceeding . Therefore the assumption that is composite is false, and since , must be prime.
∎Let be an integer with . If is composite, then has a divisor with . Consequently, if has no divisor with , then is prime.
Suppose is composite. By definition there exist integers with
We claim at least one of satisfies . Suppose instead, for contradiction, that both and . Since , multiplying these two strict inequalities preserves the direction (product of positive numbers is monotone in each argument when both sides are positive), giving
But , so we obtain , a contradiction. Hence at least one of , call it , satisfies ; and since by hypothesis, is a divisor of with . This proves the first statement. The second statement is the logical contrapositive of the first: "if composite then divisor " is equivalent to "if no divisor then not composite." Since and is not composite, by the trichotomy built into the definitions ( excluded, prime or composite exhaust the remaining cases for ), must be prime.
∎This theorem is precisely what licenses the trial-division algorithm: to test for primality, one only checks candidate divisors (or more efficiently just and the odd numbers up to ); finding none of them dividing certifies primality.
Every integer can be written as a product of one or more primes (a single prime counts as a "product" of one prime).
We argue by strong induction on , for . Base case. . Since 's only positive divisors are and , is prime, and a single prime trivially counts as a product of primes (a product with one factor). Inductive step. Let and suppose, as the strong induction hypothesis, that every integer with can be written as a product of primes. We must show can be written as a product of primes. By the Lemma above (least divisor greater than 1 is prime), has a prime divisor ; write for some integer . Case 1: . Then is itself prime, hence a product of one prime, and we are done. Case 2: . Since , we have , and because and , in fact . So satisfies (the lower bound holds because we are in the case and is an integer). By the strong induction hypothesis, can be written as a product of primes:
for some primes (with ). Then
which exhibits as a product of primes ( together with ). In both cases is a product of primes. By the principle of strong induction, every integer is a product of primes.
∎Repeatedly applying trial division — extracting a smallest prime factor (or concluding itself is prime when no such factor exists) and recursing on the quotient — produces, after finitely many steps, a complete prime factorization of any integer .
Each extraction step replaces the current number by a strictly smaller integer (since ), or halts because the current number is itself prime. The sequence of successive quotients is a strictly decreasing sequence of positive integers, hence by the Well-Ordering Principle it cannot decrease forever; it must reach a value that is prime (or , which occurs only after all prime factors have been extracted, contributing no further factor). This terminating process is exactly the constructive content of the existence proof above, so it outputs a valid prime factorization.
∎Worked examples
Example 1 — testing a moderately large odd composite by hand: . We want to know whether is prime, and if not, find its factorization, using trial division only up to . First, , so by the Trial Division Bound Theorem it suffices to test primes up to : namely .
- is odd, so .
- Digit sum , not divisible by , so .
- Does not end in or , so .
- , not an integer (, ), so .
- (, remainder ), so .
- (, remainder ), so .
- exactly: check . Indeed . ✓
So divides , with . Since is itself prime (its only divisors below to check are ; is odd and not divisible by ), we conclude
a product of two primes. Note that we found the factor before reaching , consistent with the theorem's guarantee that a composite number's smallest nontrivial factor lies at or below .
Example 2 — a number requiring the full induction argument to unwind: . This example is chosen because is one more than the product of the first four primes — a classic "does the pattern break" test case, and it illustrates that trial division, not the appearance of the number, is what determines primality. Compute , so we must test primes up to : that is .
- is odd: .
- Digit sum : not divisible by .
- Does not end in or : .
- (, remainder ): .
- (, remainder ): .
- (, remainder ): .
No prime up to divides , and by the Trial Division Bound Theorem this certifies that is prime — there is no need to test or beyond, since any composite factorization would force a factor . This illustrates the induction proof concretely: falls into the "Case 1" branch of the inductive step (), because its smallest divisor greater than turns out to be itself.
The Existence of Prime Factorization theorem requires . Consider dropping this hypothesis and asking whether can be written as a product of primes. If were required to be a product of primes with , then since every prime , the product would satisfy , contradicting . So cannot be written as a product of one or more primes — the theorem's conclusion genuinely fails at . (If one instead allows the "empty product," conventionally equal to , then is a product of zero primes — but this is a different, extended convention, not the statement proved above, and it is exactly why is excluded from being called prime or composite: admitting it as prime would force factorizations to be non-unique, since one could always append extra factors of . The hypothesis is not a cosmetic restriction; without it the clean statement " primes multiply to " is false.)
Scope, edge cases & common traps
| Situation | Correct treatment |
|---|---|
| Neither prime nor composite; excluded from both theorems above | |
| Prime (the only even prime); base case of the induction | |
| negative or zero | Primality/compositeness undefined; definitions apply only to integers |
| Testing divisors up to | Unnecessary and inefficient; suffices by the Trial Division Bound Theorem |
| Assuming factorization is unique | Not proved here — existence only; uniqueness is the Fundamental Theorem of Arithmetic |
The mathematician behind it
Origins · 1 minEuclid of Alexandria and how this was discovered
Euclid systematized the theory of divisibility and primes in Books VII–IX of the Elements, giving the first rigorous definitions of prime and composite numbers and proving foundational results including the existence of prime factors and the infinitude of primes. Almost nothing is known of his life beyond his association with the great Library of Alexandria; his mathematical legacy, transmitted through countless manuscript copies, shaped the axiomatic method itself.
Why is 1 excluded from being prime or composite?
Declaring neither prime nor composite is not arbitrary — it keeps later theorems clean. If were called prime, then factorizations would stop being unique: would all count as valid, different-length factorizations of the same number. Excluding from primality means the Fundamental Theorem of Arithmetic can assert a single factorization (up to reordering) for every integer greater than , without an asterisk about stray factors of . The exclusion is a deliberate convention chosen precisely so the uniqueness theorem remains true and simple.
Is trial division the fastest way to test primality?
No. Trial division runs in time roughly proportional to , which is efficient for small numbers (hundreds or thousands) but becomes impractical for numbers with hundreds of digits, as arise in cryptography. Modern primality tests such as Miller–Rabin (probabilistic, extremely fast) and AKS (deterministic, polynomial-time, proven correct in 2002) vastly outperform trial division for large inputs. However, trial division remains the conceptually simplest complete algorithm, and it is the natural starting point for understanding why any primality test must work.
Does the theorem in this article guarantee a unique factorization into primes?
No — this article proves only existence: every integer greater than can be written as some product of primes. It does not prove that this product is unique up to the order of the factors; that stronger and more subtle statement is the Fundamental Theorem of Arithmetic, whose proof requires an additional tool (Euclid's Lemma: if a prime divides a product, it divides one of the factors) beyond what is used here.
How do I know the trial-division search bound is correct and not just a rule of thumb?
It is a proved fact, not a heuristic: the Trial Division Bound Theorem shows that if with , then assuming both leads to , contradicting . So one of the two factors must be . This is a strict logical consequence of the ordering of real numbers, not an empirical pattern, and it holds for every composite without exception.
Can a negative integer or zero be prime?
By the standard convention used throughout elementary number theory (and in this article), primality and compositeness are defined only for integers strictly greater than . Zero and negative integers are simply outside the domain of these definitions. In more advanced settings (ring theory), the notion of "prime element" is extended to include appropriate negative integers like up to multiplication by units, but that generalization is a separate, later construction and does not apply to the elementary definitions given here.
If a number fails divisibility by 2, 3, and 5, is it automatically prime?
No — this is exactly the trap described in the warning above. Passing a few small divisibility tests only rules out those specific small primes; it says nothing about larger prime factors like up to . For example is not divisible by or , yet it is composite. Only checking every integer (or every prime) up to and finding no divisor legitimately certifies primality.
Why does the proof use strong induction rather than ordinary induction?
Ordinary induction lets you assume the statement for only, but the inductive step here needs the statement for , which can be much smaller than (e.g. for , gives , far below ). Strong induction assumes the statement for all integers from the base case up to , which is exactly the flexibility needed to invoke the hypothesis at the specific smaller value produced by dividing out a prime factor.