Fact-checked by Grok 2 weeks ago

Wilson's theorem

Wilson's theorem is a fundamental result in that characterizes prime numbers through involving factorials: an n > 1 is prime if and only if (n-1)! \equiv -1 \pmod{n}, or equivalently, n divides (n-1)! + 1. Named after the English mathematician John Wilson, the theorem was first stated by the 11th-century Persian mathematician (Alhazen), later known to , proposed by Wilson in a letter, and published by Edward Waring in Meditationes Algebraicae; Joseph-Louis Lagrange provided the first published proof in 1773. The theorem holds trivially for the prime p = 2 since $1! = 1 \equiv -1 \pmod{2}, and for odd primes, it follows from the structure of the modulo p. The theorem's —that if (n-1)! \equiv -1 \pmod{n} for n > 1, then n is prime—relies on the fact that for composite n > 4, (n-1)! is divisible by n (hence congruent to 0 n), due to the presence of distinct factors in the . Proofs of the theorem vary; one common approach pairs each a from 1 to p-2 with its modular inverse p, showing that the product (p-1)! \equiv (p-1) \pmod{p} \equiv -1 \pmod{p}. Another utilizes and , while a third employs primitive roots p to express the as a power product. Wilson's theorem has significant applications in , including as a (though computationally inefficient for large numbers due to computation) and in deriving corollaries such as that −1 is a modulo primes of the form $4k+1, where [(2k)!]^2 \equiv -1 \pmod{p}. It also aids in proving by facilitating reductions of powers and factorials modulo primes, and it generalizes to concepts like the Wilson quotient \frac{(p-1)! + 1}{p}, which is an integer for primes p and relates to properties of prime powers.

History and Context

Origins and Discovery

Wilson's theorem, which states a key congruence involving factorials and prime numbers, has roots predating its association with John Wilson, though it bears his name. The result was first stated by the Persian mathematician (Alhazen) around 1000 AD and was known to in the . It was conjectured in the by English mathematician John Wilson (1741–1793). Wilson, a distinguished scholar at the , was elected a Fellow of Peterhouse in 1764 after achieving the position of —the top student—in the 1761 examinations. As a skilled instructor in , Wilson explored various number-theoretic ideas, including the observation that would later bear his name, though he did not publish it himself. The theorem was first publicly announced by Wilson's mentor, Edward Waring (1734–1798), in his influential treatise Meditationes Algebraicae, published in in 1770. Waring, the at , explicitly credited the result to his former student , presenting it without a proof as a about the behavior of (p-1)! a prime p. This publication marked the theorem's entry into the mathematical literature, building on Wilson's unpublished explorations conducted around that time. The 1770 edition of Waring's work thus served as the primary vehicle for disseminating Wilson's insight to the broader community of European mathematicians. The discovery connected to earlier investigations into factorial congruences by prominent figures such as Leonhard Euler (1707–1783) and (1736–1813). Euler had examined related properties of s and in his studies of during the 1760s, laying groundwork for such results through his work on expansions and prime divisibility. Lagrange, in turn, provided the first rigorous proof of the theorem in 1773, demonstrating its equivalence to certain aspects of Euler's earlier findings on multiplicative inverses primes, thereby solidifying its place in . This linkage highlighted how Wilson's observation synthesized and extended prior continental European efforts on arithmetic progressions and congruences.

Naming and Early Recognition

Although the result was first published without proof by Edward Waring in his Meditationes algebraicae in 1770, the theorem is attributed to John Wilson, Waring's friend and former student, who had conjectured it around that time. Waring gave it the name "Wilson's theorem" upon publication. prominently recognized the theorem as a fundamental result in prime number theory in his (1801), explicitly referring to it as "the theorem of Wilson" in Article 75 and integrating it into his systematic treatment of congruences and primitive roots. The theorem's significance was underscored by early proofs and commentaries that demonstrated its utility prior to formal naming, including Joseph-Louis Lagrange's rigorous proof in 1773 and Augustin's subsequent analysis by Cauchy in 1813, which further emphasized its role in . Over time, the terminology evolved from Gauss's phrasing as a specific "theorem of Wilson" to the standardized "Wilson's theorem" in 19th-century literature, reflecting its central place in elementary number theory.

Statement

For Prime Moduli

Wilson's theorem, specifically for prime moduli, states that if p is a greater than , then the product of all positive integers from to p-1 satisfies the (p-1)! \equiv -[1](/page/1) \pmod{p}. This relation highlights a distinctive property of primes in the context of , where the (p-1)! represents the multiplication of the nonzero residue classes modulo p. The assumes familiarity with , in which a \equiv b \pmod{p} means that p divides a - b, and with the definition of a prime as an greater than 1 having no positive divisors other than 1 and itself. Since p is prime, each from 1 to p-1 is coprime to p, allowing the to be computed as a product within the of integers modulo p. Equivalently, the theorem implies that the Wilson's quotient W_p = \frac{(p-1)! + 1}{p} is an whenever p is prime. This integer-valued expression provides an alternative way to express the theorem's condition. In contrast to the prime case, the fails for most composite moduli.

For Composite Moduli

Wilson's theorem fails to hold for composite moduli n > 1, as (n-1)! \not\equiv -1 \pmod{n}. In fact, the (n-1)! \equiv -1 \pmod{n} is true n is prime. For composite n > 4, the factorial (n-1)! is divisible by n, so (n-1)! \equiv 0 \pmod{n}. This occurs because n has prime factors whose multiples appear sufficiently often in the product $1 \times 2 \times \cdots \times (n-1) to account for the full factorization of n. Specifically, if n = ab with distinct primes $1 < a < b < n, then both a and b divide (n-1)!, hence so does n. For n = p^k with prime p and k \geq 2, multiples of p up to n-1 ensure at least k factors of p in (n-1)!, so n divides it. The case n = 4 is an exception among composites, where $3! = 6 \equiv 2 \pmod{4}, neither $0 nor -1 \equiv 3 \pmod{4}. Consequently, for composite n > 4, (n-1)! + 1 \equiv 1 \pmod{n}, failing the prime condition. While the basic congruence holds for all primes, rare primes known as (5, 13, 563) satisfy the stronger condition (p-1)! + 1 \equiv 0 \pmod{p^2}.

Examples and Illustrations

Basic Numerical Example

Wilson's theorem states that for a p, the (p-1)! is congruent to -1 modulo p. A basic example is the prime p = 5. Compute $4! = 1 \times 2 \times 3 \times 4 = 24. To find $24 \mod 5, note that $5 \times 4 = 20 and $24 - 20 = 4, so $24 \equiv 4 \pmod{5}. Since $4 + 1 = 5, which is divisible by 5, it follows that $4 \equiv -1 \pmod{5}. Thus, $4! \equiv -1 \pmod{5}. For the prime p = 7, first compute $6! = 1 \times 2 \times 3 \times 4 \times 5 \times 6 = 720. To verify the congruence, observe that $720 + 1 = 721 and $721 = [7](/page/+7) \times 103, since [7](/page/+7) \times 100 = 700 and [7](/page/+7) \times 3 = 21, so 721 is divisible by 7. Therefore, $720 \equiv -1 \pmod{[7](/page/+7)}. The pattern holds for smaller and larger small primes as well. The following table shows (p-1)! \mod p for the primes p = 2, 3, 5, [7](/page/+7), 11, confirming the result equals -1 \mod p in each case:
Prime p(p-1)!(p-1)! \mod p-1 \mod p
21! = 111
32! = 222
54! = 2444
76! = 72066
1110! = 3,628,8001010
These computations illustrate the theorem's consistency for small primes.

Wilson's Quotient

The Wilson's quotient W_p for a positive integer p > 1 is defined as W_p = \frac{(p-1)! + 1}{p}. By Wilson's theorem, W_p is an integer if and only if p is prime. For illustration, consider p = 11, a prime. Here, $10! = 3,628,800, so W_{11} = \frac{3,628,800 + 1}{11} = \frac{3,628,801}{11} = 329,891, which is an integer. While the integrality of W_p provides a clear indicator of primality, it is interesting to note that W_p itself is prime for certain primes p, such as p = 5 where W_5 = 5. However, the primary significance lies in its equivalence to the condition in Wilson's theorem. Computing W_p directly for large primes p presents significant challenges, as the factorial (p-1)! grows extremely rapidly, requiring substantial computational resources even for moderately sized p.

Proofs

Proof for Composite Moduli

For composite moduli n > 4, Wilson's theorem fails because (n-1)! \equiv 0 \pmod{n}, which cannot equal -1 \pmod{n} since n > 1. This congruence arises from the structure of the composite number, where the prime factors of n appear with sufficient multiplicity in the product $1 \cdot 2 \cdots (n-1) to make n itself a divisor of (n-1)!. Consider first the case where n admits a n = ab with distinct integers $1 < a < b < n. In this situation, both a and b are distinct terms in the product defining (n-1)!, so their product ab = n divides (n-1)!, yielding (n-1)! \equiv 0 \pmod{n}. For example, if n = 6 = 2 \cdot 3, then $5! = 120, and $120 \div 6 = 20, confirming the congruence. Now address cases where factors repeat, such as when n = p^k for a prime p and k \geq 2. Here, the exponent of p in the prime factorization of (n-1)! is given by \sum_{m=1}^{\infty} \left\lfloor \frac{n-1}{p^m} \right\rfloor. For n > 4, this sum exceeds or equals k, ensuring p^k divides (n-1)! and thus (n-1)! \equiv 0 \pmod{n}. For instance, with n = 9 = [3^2](/page/3-2), the exponent of 3 in $8! is \left\lfloor 8/3 \right\rfloor + \left\lfloor 8/9 \right\rfloor = 2 + 0 = 2, so 9 divides 40320, and $40320 \equiv 0 \pmod{9}. Similar multiplicity holds for higher powers or products involving repeated primes greater than 4. The remaining composite case is n = 4. Direct computation gives (4-1)! = 6 \equiv 2 \pmod{4}, which is distinct from both 0 and -1 \equiv 3 \pmod{4}. In all composite scenarios, the resulting prevents (n-1)! + 1 from being divisible by n, as required by the theorem for primes; specifically, adding 1 to 0 n yields 1, not 0, while the case of 4 yields 3, also not 0 4. This establishes the converse, originally proved by Lagrange in , that the condition holds n is prime.

Elementary Proof for Primes

The elementary proof of Wilson's theorem for a prime p relies on the structure of the of integers p, denoted (\mathbb{Z}/p\mathbb{Z})^\times, which consists of the residues $1, 2, \dots, p-1 and forms a since p is prime, ensuring every non-zero element has a unique p. To establish (p-1)! \equiv -1 \pmod{p}, consider the product of all elements in \{1, 2, \dots, p-1\}. Each element k (where $1 < k < p-1) pairs with its distinct modular inverse k^{-1} such that k \cdot k^{-1} \equiv [1](/page/1) \pmod{p}, because if k \equiv k^{-1} \pmod{p}, then k^2 \equiv [1](/page/1) \pmod{p}, implying k \equiv [1](/page/1) \pmod{p} or k \equiv -[1](/page/1) \pmod{p} (i.e., k = p-1), which are the only self-inverse elements. This pairing accounts for p-2 elements (all except $1 and p-1) into (p-2)/2 pairs, each contributing a factor of $1 to the product modulo p. The remaining unpaired elements are $1 and p-1 \equiv -1 \pmod{p}, so their product is $1 \cdot (-1) \equiv -1 \pmod{p}. Therefore, (p-1)! \equiv -1 \pmod{p}. This holds for odd primes p > 2; the cases p=2 and p=3 are verified directly as $1! \equiv 1 \equiv -1 \pmod{2} and $2! = 2 \equiv -1 \pmod{3}.

Proof Using Fermat's Little Theorem

Fermat's Little Theorem states that if p is a and a is an not divisible by p, then a^{p-1} \equiv 1 \pmod{p}. This theorem implies that every nonzero residue class modulo p—namely, the integers $1, 2, \dots, p-1—satisfies the congruence k^{p-1} \equiv 1 \pmod{p}, making each of these integers a root of the X^{p-1} - 1 \equiv 0 \pmod{p}. Consider the monic polynomial of degree p-1 whose roots are precisely these nonzero residues: \prod_{k=1}^{p-1} (X - k). Since X^{p-1} - 1 is also a monic polynomial of degree p-1 with the same roots modulo p, the two polynomials must be congruent modulo p: \prod_{k=1}^{p-1} (X - k) \equiv X^{p-1} - 1 \pmod{p}. Expanding the left side gives a polynomial X^{p-1} + c_{p-2} X^{p-2} + \cdots + c_1 X + c_0, where the constant term c_0 = (-1)^{p-1} \prod_{k=1}^{p-1} k = (-1)^{p-1} (p-1)!. The constant term of the right side is -1. Equating the constant terms yields (-1)^{p-1} (p-1)! \equiv -1 \pmod{p}. For the case p = 2, Wilson's theorem holds trivially since $1! = 1 \equiv -1 \pmod{2}. For odd primes p > 2, p-1 is even, so (-1)^{p-1} = 1 and thus (p-1)! \equiv -1 \pmod{p}. This establishes Wilson's theorem as a direct consequence of through the equality of these polynomials p.

Group-Theoretic Proof Using Sylow Theorems

The multiplicative group (\mathbb{Z}/p\mathbb{Z})^\times, denoted G, consists of the integers from 1 to p-1 under multiplication modulo p, where p is an odd prime. This group is cyclic of order p-1, which is even. Since 2 divides |G|, Sylow's theorems guarantee the existence of a Sylow 2-subgroup of G. As G is cyclic, all its subgroups are unique for each divisor of the order, so the Sylow 2-subgroup P is unique, normal, and itself cyclic of order $2^k, where $2^k is the highest power of 2 dividing p-1. Wilson's theorem is equivalent to the statement that the product of all elements of G is -1 modulo p, as this product is precisely (p-1)! modulo p. In a finite cyclic group of even order, there is a unique element of order 2. To identify it, solve x^2 \equiv 1 \pmod{p}, or (x-1)(x+1) \equiv 0 \pmod{p}. Since \mathbb{Z}/p\mathbb{Z} is a , the solutions are x \equiv 1 \pmod{p} and x \equiv -1 \pmod{p}, with -1 \not\equiv 1 \pmod{p} for p > 2. Thus, -1 is the unique element of order 2 in G, generating the unique subgroup of order 2, which is contained in the Sylow 2-subgroup P. In a finite abelian group, the product of all elements equals the product of the elements of order dividing 2 (the 2-torsion subgroup). Here, the 2-torsion subgroup is \{1, -1\}, so its product is $1 \cdot (-1) = -1. Therefore, the product of all elements of G is -1 modulo p, proving Wilson's theorem. This result follows from the structure of abelian groups and was established using elementary group-theoretic properties.

Applications

Primality Testing

Wilson's theorem provides a deterministic for primality: a positive n > 1 is prime (n-1)! \equiv -1 \pmod{n}. This yields a straightforward primality testing —compute the (n-1)! n and check whether the result equals n-1—which conclusively proves primality when the condition holds, as the converse of the theorem is also true. Despite its theoretical elegance, the direct application faces significant computational limitations, requiring O(n) time to evaluate the even when computed n, rendering it inefficient for large n beyond a few thousand digits. It remains practical only for verifying small primes or in theoretical contexts where exhaustive computation is feasible. Historically, the converse served as one of the earliest primality tests, with proving its validity in 1773 and noting its laborious nature, though it found limited use in manual computations before electronic computers. In the pre-AKS era (prior to 2002), it appeared in foundational primality provers as a for deterministic verification, often combined with trial division for initial sieving. Other deterministic tests exist for specific forms, such as the Lucas-Lehmer test for Mersenne primes, and hybrid approaches pairing Wilson's criterion with probabilistic methods such as Miller-Rabin for faster large-scale testing, though these do not alter the core computation.

Quadratic Residues

Wilson's theorem provides a powerful tool for analyzing quadratic residues modulo an odd prime p. The theorem's pairing argument in its proof reveals that the squares $1^2, 2^2, \dots, \left(\frac{p-1}{2}\right)^2 are all distinct modulo p. To see this, suppose k^2 \equiv m^2 \pmod{p} for $1 \le m < k \le \frac{p-1}{2}. Then p divides (k - m)(k + m), so p divides k - m or k + m. Since $1 \le m < k \le \frac{p-1}{2}, neither k - m nor k + m is divisible by p, a contradiction. Thus, there are exactly \frac{p-1}{2} distinct nonzero quadratic residues modulo p. A key application of Wilson's theorem is determining when -1 is a quadratic residue modulo p. Consider the product (p-1)! \equiv \prod_{k=1}^{(p-1)/2} k \cdot \prod_{k=(p+1)/2}^{p-1} k \pmod{p}. The second product is \prod_{k=1}^{(p-1)/2} (p - k) \equiv \prod_{k=1}^{(p-1)/2} (-k) = (-1)^{(p-1)/2} \left[ \left( \frac{p-1}{2} \right)! \right]^2 \pmod{p}, since the first product is \left( \frac{p-1}{2} \right)!. By Wilson's theorem, (p-1)! \equiv -1 \pmod{p}, so (-1)^{(p-1)/2} \left[ \left( \frac{p-1}{2} \right)! \right]^2 \equiv -1 \pmod{p}. Rearranging gives \left[ \left( \frac{p-1}{2} \right)! \right]^2 \equiv -(-1)^{(p-1)/2} \pmod{p}. If p \equiv 1 \pmod{4}, then (p-1)/2 is even, so (-1)^{(p-1)/2} = 1 and \left[ \left( \frac{p-1}{2} \right)! \right]^2 \equiv -1 \pmod{p}. Thus, \left( \frac{p-1}{2} \right)! is a square root of -1 modulo p, implying -1 is a modulo p. If p \equiv 3 \pmod{4}, then (p-1)/2 is odd, so (-1)^{(p-1)/2} = -1 and \left[ \left( \frac{p-1}{2} \right)! \right]^2 \equiv 1 \pmod{p}, showing -1 is not a quadratic residue modulo p.

Formulas for Prime Factorials

Wilson's theorem provides an explicit congruence for the factorial of a prime minus one: for a prime p, (p-1)! \equiv -1 \pmod{p}. This implies that p divides (p-1)! + 1, so there exists an integer m, known as the , such that (p-1)! = -1 + m p. The Wilson quotient m = \frac{(p-1)! + 1}{p} is always an integer for prime p. A special case arises with , which are primes p such that p^2 divides (p-1)! + 1, or equivalently, the Wilson quotient m \equiv 0 \pmod{p} and (p-1)! \equiv -1 \pmod{p^2}. The only known are 5, 13, and 563; exhaustive searches have found no others up to $2 \times 10^{13} as of 2014. For these primes, the formula simplifies to (p-1)! = -1 + k p^2 for some integer k. Another formula derives from pairing terms in the product for (p-1)!. For odd prime p, the product pairs as k and p-k \equiv -k \pmod{p} for k = 1 to (p-1)/2, yielding (p-1)! \equiv (-1)^{(p-1)/2} \left( \left( \frac{p-1}{2} \right)! \right)^2 \pmod{p}. Combining with gives \left( \left( \frac{p-1}{2} \right)! \right)^2 \equiv (-1)^{(p+1)/2} \pmod{p}. Dividing the paired form by the square of the half-factorial then produces \frac{(p-1)!}{\left( \left( \frac{p-1}{2} \right)! \right)^2} \equiv (-1)^{(p-1)/2} \pmod{p}. These relations express (p-1)! in terms of smaller factorials modulo p. Stirling's approximation offers an asymptotic expression for (p-1)! itself: (p-1)! \approx \sqrt{2 \pi (p-1)} \left( \frac{p-1}{e} \right)^{p-1}, which, when combined with the exact divisibility from , allows estimation of the Wilson quotient m \approx \frac{(p-1)!}{p}. This approximation aids in computational verification of modulo higher powers of p, such as for detecting , though exact computation requires additional adjustments for precision.

p-adic Gamma Function

The p-adic gamma function provides a p-adic analytic continuation of the factorial function, adjusted to remove factors divisible by the prime p, and serves as a key tool in p-adic number theory. It interpolates values like the product of integers up to n not divisible by p, with a sign convention that ensures consistency with modular arithmetic properties such as . This function takes values in the multiplicative group of p-adic units \mathbb{Z}_p^\times and is continuous on the p-adic integers \mathbb{Z}_p. For a prime p and positive integer n, the Morita p-adic gamma function is defined by \Gamma_p(n) = (-1)^n \prod_{\substack{0 < j < n \\ p \nmid j}} j. This finite product is extended to all x \in \mathbb{Z}_p by taking the limit \Gamma_p(x) = \lim_{k \to \infty} (-1)^{n_k} \prod_{\substack{0 < j < n_k \\ p \nmid j}} j, where the positive integers n_k converge to x in the p-adic topology. The limit exists because the partial products remain p-adic units, a property ensured by , which implies that for n a multiple of p-1, the product over a complete set of residues modulo p is congruent to -1 modulo p, bounding the p-adic norm. In particular, at n = p, \Gamma_p(p) = (-1)^p (p-1)!, and Wilson's theorem yields \Gamma_p(p) \equiv 1 \pmod{p} for odd p, confirming it lies in \mathbb{Z}_p^\times. The interpolation property of \Gamma_p enables evaluation at non-integer p-adic arguments, facilitating applications in p-adic analysis beyond discrete factorials. For instance, since $1-p \equiv 1 \pmod{p} and \Gamma_p(1) = -1, continuity implies \Gamma_p(1-p) \equiv -1 \pmod{p}. The functional equation \Gamma_p(z+1) = -z \Gamma_p(z) for z \in \mathbb{Z}_p with p \nmid z further allows computation of such values, linking back to through the modular consistency of the products. Yasutaka Morita introduced the p-adic gamma function in 1975 as part of his work on p-adic analogs of classical special functions. It has since played a central role in Iwasawa theory, where it appears in expressions for p-adic L-functions and measures on the p-adic units, connecting number-theoretic congruences like those from to broader analytic structures.

Generalizations

Gauss's Generalization

Carl Friedrich Gauss provided a significant extension of Wilson's theorem in his seminal work Disquisitiones Arithmeticae (1801), specifically in Article 76, where he generalized the product over all nonzero residues modulo a prime to products over specific subsets defined by primitive roots. This generalization considers the product of all integers from 1 to n-1 that are coprime to n, known as the product over the units in (\mathbb{Z}/n\mathbb{Z})^\times. The precise statement is as follows: For any integer n \geq 2, it is the product \prod_{a=1, \gcd(a,n)=1}^{n-1} a. Then, \prod_{\substack{1 \leq a < n \\ \gcd(a,n)=1}} a \equiv \begin{cases} -1 \pmod{n} & \text{if } n = 2, 4, p^k, \text{ or } 2p^k \text{ for odd prime } p \text{ and } k \geq 1, \\ 1 \pmod{n} & \text{otherwise}. \end{cases} The condition on the right corresponds exactly to the moduli n for which the multiplicative group (\mathbb{Z}/n\mathbb{Z})^\times admits a primitive root (i.e., is cyclic). This recovers immediately for prime moduli p, since for odd prime p, the product is (p-1)! \equiv -1 \pmod{p}. Gauss's proof relies on the existence of primitive roots and the structure of the multiplicative group. Assuming a primitive root g modulo n exists, the units are precisely the powers g^0, g^1, \dots, g^{\phi(n)-1} modulo n. The product is then \prod_{j=0}^{\phi(n)-1} g^j = g^{\sum_{j=0}^{\phi(n)-1} j} = g^{\phi(n)(\phi(n)-1)/2}. Since g^{\phi(n)} \equiv 1 \pmod{n}, this simplifies to g^{\phi(n)(\phi(n)-1)/2} \equiv (g^{\phi(n)/2})^{(\phi(n)-1)} \pmod{n}. For moduli with primitive roots, g^{\phi(n)/2} \equiv -1 \pmod{n} (as the order is \phi(n), so the unique element of order 2 is -1), yielding (-1)^{\phi(n)-1} \equiv -1 \pmod{n} because \phi(n) is even for such n > 2. For moduli without primitive roots, the product pairs to 1. This approach highlights the cyclic nature of the group for those n.

Wolstenholme's Theorem

Wolstenholme's theorem provides a refinement of congruences involving factorials and harmonic sums for prime moduli, extending ideas from to higher powers of primes. Specifically, for a p \geq 5, the (p-1)-th H_{p-1} = \sum_{k=1}^{p-1} \frac{1}{k} satisfies H_{p-1} \equiv 0 \pmod{p^2}, meaning that when H_{p-1} is expressed as a reduced a/b, the prime p^2 divides the numerator a. An equivalent formulation of the theorem involves binomial coefficients: for the same primes p \geq 5, \binom{2p-1}{p-1} \equiv 1 \pmod{p^3}. This congruence links the harmonic sum to combinatorial identities, as the binomial coefficient can be related to products that mirror the denominator structure in the harmonic number's fractional representation. The theorem connects to Wilson's theorem, which states that (p-1)! \equiv -1 \pmod{p} for prime p, by examining higher-order divisibility properties. While Wilson's theorem implies that p divides (p-1)! + 1, Wolstenholme's result shows that for the associated harmonic sum, p^2 divides the numerator, providing a stronger condition on the distribution of inverses modulo p. For most primes, (p-1)! + 1 is divisible by p but not by p^2, with exceptions known as Wilson primes; Wolstenholme's theorem refines this by ensuring the harmonic congruence holds to order p^2 without such exceptions for p \geq 5. Joseph Wolstenholme discovered the theorem in 1862 while studying properties of prime numbers, publishing it in his paper "On certain properties of prime numbers." The result is related to Bernoulli numbers through extensions and proofs that involve the von Staudt–Clausen theorem, where the non-divisibility of certain Bernoulli numbers B_k (for even k < p-1) by p contributes to the congruence's validity modulo higher powers. A standard proof outline proceeds by expressing H_{p-1} in terms of the denominator, leveraging Wilson's theorem to handle inverses p. One approach pairs terms in the using the \frac{1}{k} + \frac{1}{p-k} = \frac{p}{k(p-k)}, reducing the sum to p times a whose numerator is analyzed p^2. Further steps involve summing quadratic residues or using generating functions to show the necessary divisibility, often incorporating partial fraction decompositions of rational functions p^2.

References

  1. [1]
    Wilson's Theorem -- from Wolfram MathWorld
    This theorem was proposed by John Wilson and published by Waring (1770), although it was previously known to Leibniz. It was proved by Lagrange in 1773.
  2. [2]
    Wilson's Theorem | Brilliant Math & Science Wiki
    Wilson's theorem states that a positive integer n>1 is a prime if and only if (n−1)!≡−1(modn), meaning (n-1)! is 1 less than a multiple of n.
  3. [3]
    [PDF] Three proofs of Wilson's theorem
    Wilson's theorem states that for a prime p, (p-1)! is congruent to -1 (mod p).
  4. [4]
    Wilson's Theorem and Fermat's Theorem
    . They are often used to reduce factorials and powers mod a prime. I'll prove Wilson's theorem first, then use it to prove Fermat's theorem.
  5. [5]
    John Wilson - Biography - MacTutor - University of St Andrews
    From there he entered Peterhouse, Cambridge matriculating on 29 June 1757, and he was the Senior Wrangler in 1761. This means that he was the best of all the ...
  6. [6]
    Meditationes Algebraicae : Edward Waring - Internet Archive
    Sep 21, 2014 · PDF download · download 1 file · SINGLE PAGE PROCESSED JP2 ZIP download · download 1 file · TORRENT download · download 15 Files · download 6 ...
  7. [7]
    Earliest Known Uses of Some of the Words of Mathematics (W)
    WILSON's THEOREM was given its name by Edward Waring (1734-1798) for his friend, John Wilson (1741-1793). The first published statement of the theorem was ...
  8. [8]
    Disquisitiones arithmeticae : Gauss, Carl Friedrich, 1777-1855
    Aug 11, 2018 · Disquisitiones arithmeticae. by: Gauss, Carl Friedrich, 1777-1855. Publication date: 1801. Topics: Number theory. Publisher: Lipsiae : In ...Missing: Wilson's article 76
  9. [9]
    Joseph-Louis Lagrange (1736 - 1813) - Biography - MacTutor
    In 1771 he proved Wilson's theorem (first stated without proof by Waring) ... theory continued by Ruffini, Galois and Cauchy. Although Lagrange had made ...
  10. [10]
    3.10 Wilson's Theorem and Euler's Theorem
    Similar in spirit, and very useful, is Euler's Theorem: Theorem 3.10. 5 If n>0, and u is relatively prime to n, then uϕ(n)≡1(modn). Proof.
  11. [11]
    A proof of Wilson's Theorem - The Prime Pages
    Wilson's theorem states: Let p be an integer greater than one. p is prime if and only if (p-1)! = -1 (mod p). Here we prove this theorem and provide links ...Missing: statement | Show results with:statement
  12. [12]
    [PDF] A86 INTEGERS 22 (2022) A note on the Wilson quotient
    Sep 12, 2022 · Based on this theorem the Wilson quotient Wp of p is defined by. Wp := (p − 1)! + 1 p. ∈ Z. If Wp ≡ 0 (mod p), or equivalently, if (p − 1)! ...Missing: theory | Show results with:theory
  13. [13]
    [PDF] MAT246H1S Lec0101 Burbulla
    What happens to the conclusion of Wilson's Theorem if m is composite? We obtain a very different result: Theorem: if m is a composite number larger than 4, then.
  14. [14]
    Wilson Prime -- from Wolfram MathWorld
    A Wilson prime is a prime satisfying W(p)=0 (mod p), where W(p) is the Wilson quotient, or equivalently, (p-1)!=-1 (mod p^2). The first few Wilson primes ...Missing: criterion | Show results with:criterion
  15. [15]
    A007619 - OEIS
    ### Summary of Wilson Quotient from A007619
  16. [16]
    Wilson Quotient -- from Wolfram MathWorld
    The quotient W(p)=((p-1)!+1)/p which must be congruent to 0 (mod p) for p to be a Wilson prime. The quotient is an integer only when p=1 (in which case ...Missing: definition | Show results with:definition
  17. [17]
    [PDF] A search for Wieferich and Wilson primes - Dartmouth Mathematics
    Abstract. An odd prime p is called a Wieferich prime if. 2p−1 ≡ 1 (mod p2); alternatively, a Wilson prime if. (p − 1)! ≡ −1 (mod p2).
  18. [18]
    [PDF] Solutions to Introduction to Analytic Number Theory Tom M. Apostol
    Prove the converse of Wilson's theorem: If (n − 1)! + 1 ≡ 0 mod n, then n is prime if n > 1. Lemma 5.7. If n is composite and n 6= 4 then n (n − 1)! ...
  19. [19]
    [PDF] Lagrange's Proof of the Converse of Wilson's Theorem
    Jul 1, 2023 · In this project, we have studied Lagrange's proof of the converse of Wilson's Theorem. We've also seen that the converse provides a primality ...
  20. [20]
    [PDF] CYCLICITY OF (Z/(p)) 1. Introduction For a prime p, the group (Z/(p ...
    We will give ten proofs that (Z/(p))× is cyclic. A feature of all known proofs is that they do not lead to concrete formula for a generator in terms of p. The ...
  21. [21]
    A New Proof of the Generalized Wilson's Theorem - jstor
    BY G. A. MILLER. BY employing several elementary theorems of substitution groups it is pos- sible to give a very simple proof of Wilson's theorem in the ...
  22. [22]
    [PDF] a survey of primality tests
    Aug 27, 2014 · Next we prove Wilson's theorem, which is itself a primality test. Theorem 6.2 (Wilson's Theorem). A positive integer p is prime if and only ...
  23. [23]
    [PDF] Lagrange's Study of Wilson's Theorem - Ursinus Digital Commons
    Jun 30, 2023 · Lagrange also noticed a connection between his proof and “the famous Theorem of Fermat for which Euler has given several proofs.” The famous ...
  24. [24]
    [PDF] Primality testing: variations on a theme of Lucas - People | MIT CSAIL
    This survey traces an idea of Édouard Lucas that is a common el- ement in various primality tests. These tests include those based on Fermat's little ...
  25. [25]
  26. [26]
    [1209.3436] A search for Wilson primes - arXiv
    Sep 15, 2012 · Abstract:A Wilson prime is a prime p such that (p-1)! = -1 mod p^2. We report on a search for Wilson primes up to 2 * 10^13, and describe ...
  27. [27]
    [PDF] WHEN IS −1 A SQUARE MODULO PRIMES? When p is an odd ...
    The conclusion of Wilson's theorem is always false if the prime p is replaced by a composite number n: when n is composite we can't have (n − 1)! ≡ −1 mod n, ...<|control11|><|separator|>
  28. [28]
    A search for Wilson primes - American Mathematical Society
    Jan 27, 2014 · We report on a search for Wilson primes up to 2 × 1013, and describe several new algorithms that were used in the search. In particular, we give ...Missing: limit | Show results with:limit
  29. [29]
    [PDF] adic $\Gamma$-function - Benedict H. Gross; Neal Koblitz
    Mar 7, 2004 · Morita's p-adic gamma function. The field L contains the (p-1)-st ... by Wilson's Theorem. -∞. PXj. LEMMA 2.4. Assume 0 <r/N <1 and ...
  30. [30]
    On Morita's p-adic gamma function
    Introduction and notations. Letp be a prime, N, OS, lp, Qp, Cp as usual (2). The absolute value (resp. the valuation). onZp, Qp, Cp is denoted by |.
  31. [31]
    [PDF] SOME PROPERTIES OF THE GENERALIZED p-ADIC GAMMA ...
    Jun 1, 2024 · The ring of p-adic integers Zp contains the p-adic numbers which satisfy |x|p ≤ 1. 2.1 p-adic Factorial and p-adic Gamma Function. In this ...
  32. [32]
    [PDF] extensions of the gauss-wilson theorem - FTP Server of the GWDG
    depends on the fact that any integer a with 1 <a<p − 1 has its inverse a−1 $≡ a (mod p). Somewhat less well-known is Gauss' generalization of Wilson's theorem.
  33. [33]
    Why does $(\frac{p-1}{2}!)^2 = (-1)^{\frac{p+1}{2}}$ mod $p
    Apr 13, 2012 · Using Wilson's theorem and Fermat's little theorem, it's equivalent to saying 224262⋯(p−1)2=(−1)p+12 mod p, but I can't figure out any more than ...Show that: $-1 \equiv (-1)^{(p-1)/2}x^2 \pmod p - Math Stack ExchangeIf P is prime, prove that $(p-1)!$ is congruent to $(p-1)$ $\pmod {1+2 ...More results from math.stackexchange.com
  34. [34]
    [PDF] Notes on Wolstenholme's Theorem
    Oct 12, 2008 · Wolstenholme's Theorem: p2 divides the numerator of the re- duced form of H(p − 1). Proof. We prove the assertion using a sequence of claims.
  35. [35]
    Wolstenholme's theorem: Its Generalizations and Extensions in the ...
    Nov 13, 2011 · We present and compare several generalizations and extensions of Wolstenholme's theorem obtained in the last hundred and fifty years.
  36. [36]
    Bernoulli Numbers, Wolstenholme's Theorem, and p^5 Variations of ...
    Feb 10, 2006 · Abstract page for arXiv paper math/0303332: Bernoulli Numbers, Wolstenholme's Theorem, and p^5 Variations of Lucas' Theorem.