Fermat's theorem
Our editors will review what you’ve submitted and determine whether to revise the article.
Join Britannica's Publishing Partner Program and our community of experts to gain a global audience for your work! Key People:
 Pierre de Fermat
 Related Topics:
 Number theory Prime
Fermat’s theorem, also known as Fermat’s little theorem and Fermat’s primality test, in number theory, the statement, first given in 1640 by French mathematician Pierre de Fermat, that for any prime number p and any integer a such that p does not divide a (the pair are relatively prime), p divides exactly into a^{p} − a. Although a number n that does not divide exactly into a^{n} − a for some a must be a composite number, the converse is not necessarily true. For example, let a = 2 and n = 341, then a and n are relatively prime and 341 divides exactly into 2^{341} − 2. However, 341 = 11 × 31, so it is a composite number (a special type of composite number known as a pseudoprime). Thus, Fermat’s theorem gives a test that is necessary but not sufficient for primality.
As with many of Fermat’s theorems, no proof by him is known to exist. The first known published proof of this theorem was by Swiss mathematician Leonhard Euler in 1736, though a proof in an unpublished manuscript dating to about 1683 was given by German mathematician Gottfried Wilhelm Leibniz. A special case of Fermat’s theorem, known as the Chinese hypothesis, may be some 2,000 years old. The Chinese hypothesis, which replaces a with 2, states that a number n is prime if and only if it divides exactly into 2^{n} − 2. As proved later in the West, the Chinese hypothesis is only half right.
Learn More in these related Britannica articles:

number theory: Pierre de Fermat…stated what is known as Fermat’s little theorem—namely, that if
p is prime anda is any whole number, thenp divides evenly intoa ^{p} −a . Thus, ifp = 7 anda = 12, the farfromobvious conclusion is that 7 is a divisor of 12^{7} − 12 =… 
Pierre de Fermat: Work on theory of numbers of Pierre de Fermat…important result, now known as Fermat’s lesser theorem, asserts that if
p is a prime number and ifa is any positive integer, thena ^{p} a is divisible byp . Fermat seldom gave demonstrations of his results, and in this case proofs were provided by Gottfried Leibniz, the 17thcentury… 
pseudoprime…de Fermat first asserted “Fermat’s Little Theorem,” also known as Fermat’s primality test, which states that for any prime number
p and any integera such thatp does not dividea (in this case, the pair are called relatively prime),p divides exactly intoa ^{p} −a . Although…