The Wayback Machine - https://web.archive.org/web/20250402191456/https://www.geeksforgeeks.org/wilsons-theorem/
Open In App

Wilson’s Theorem

Last Updated : 14 Oct, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

Wilson’s Theorem is a fundamental result in number theory that provides a necessary and sufficient condition for determining whether a given number is prime. It states that a natural number p > 1 is a prime number if and only if:

(p – 1)! ≡ −1 (mod p)

This means that the factorial of p – 1 (the product of all integers from 1 to p – 1) is congruent to −1 modulo p. In simpler terms, if you take the factorial of one less than a prime number and divide it by that prime number, the remainder will be p – 1.

Wilson’s Theorem Examples

Example for Prime Number

Let’s check for p = 5

Calculate (5 – 1)! = 4! = 24
Check 24 mod  5 = 4 which is indeed -1 mod  5
Thus, 5 is prime.

Example of Composite Number:

For p = 4

Calculate (4 – 1)! = 3! = 6
Check 6 mod  4 = 2 which is not -1 mod  4
Thus, 4 is not prime.

Applications of Wilson’s Theorem

While Wilson’s Theorem is theoretically significant, its direct application in practical prime number testing is limited due to computational inefficiency. Nonetheless, it serves as a fundamental example of prime number properties in theoretical mathematics and is often referenced in discussions about primality testing.

Read More:

FAQs on Wilson’s Theorem

What is Wilson’s Theorem?

Wilson’s Theorem states that a natural number p > 1 is a prime number if and only if:

(p – 1)! ≡ -1 (mod p)

Who discovered Wilson’s Theorem?

Wilson’s Theorem is named after the English mathematician John Wilson, who formulated the theorem in the 18th century. It was later popularized by mathematicians such as Leonard Euler.

Are there any limitations to Wilson’s Theorem?

Yes, the theorem is not efficient for large numbers. Calculating (p – 1)! becomes impractical as p increases. Consequently, while it provides a theoretical framework for primality testing, more efficient algorithms (such as the Sieve of Eratosthenes or probabilistic tests) are preferred for large primes.


Next Article

Similar Reads

three90RightbarBannerImg