Fermat's Little Theorem
"For a prime p and any integer a, a raised to the p leaves the same remainder as a itself when divided by p."
"For a prime p and any integer a, a raised to the p leaves the same remainder as a itself when divided by p."
Fermat's little theorem states that if p is a prime number, then for any integer a, the number a raised to the power p minus a is a multiple of p; in the language of modular arithmetic, a to the p is congruent to a modulo p. Equivalently, when a is not divisible by p, a raised to the power p minus one is congruent to one modulo p. Named to distinguish it from Fermat's far deeper last theorem, it is a cornerstone of elementary number theory and modular arithmetic, and it underlies both primality testing and the mathematics of public-key cryptography, most famously the RSA cryptosystem.
a^p \equiv a \pmod{p}Rated Empirical: grounded in studies or measurable evidence. The other 608.
The theorem captures a hidden regularity in how powers behave modulo a prime. Because the non-zero residues modulo a prime form a group under multiplication, raising any of them to the power one less than the prime cycles back to one, which gives the congruence. Multiplying through by a extends it to cover the case where a is divisible by p, where both sides are zero. Euler generalised the result: for any modulus n and any a coprime to it, a raised to the power of Euler's totient of n is congruent to one, with Fermat's theorem the special case of a prime modulus, whose totient is one less than the prime.
The generalisation to any modulus, that a raised to Euler's totient of n is congruent to one when a and n are coprime, of which Fermat's little theorem is the prime-modulus case.
A fast probabilistic check for primality using the theorem's contrapositive, whose blind spots are the Fermat pseudoprimes and, worst of all, the Carmichael numbers.
Fermat's little theorem is a foundational result of number theory that turns the behaviour of powers modulo a prime into a simple, exploitable identity. It underpins the Fermat primality test and, through Euler's generalisation, the RSA cryptosystem that secures much of digital communication, so a seventeenth-century observation about remainders now protects online commerce. It is also a gateway to the group theory of modular arithmetic and to deeper results, and it stands as a classic example of how an elegant fact about primes can become a workhorse of modern technology.
The converse of the theorem is false: passing the Fermat test does not prove a number prime, because the Carmichael numbers are composite yet satisfy the congruence for every base coprime to them, the smallest being 561. The theorem is a statement about primes, and its primality test is only a probabilistic screen, not a proof of primality, so cryptographic and computational uses pair it with stronger tests. Its power is real but bounded, giving a necessary condition for primality rather than a sufficient one.
Fermat's little theorem is not Fermat's last theorem; the little theorem is a modular-arithmetic identity, while the last theorem is the far deeper claim that no positive integers satisfy the equation for exponents above two. The converse of the little theorem does not hold, so a number passing the Fermat test can still be composite, as the Carmichael numbers show. And the coprime form requires a not to be divisible by the prime, the case handled separately by the more general a-to-the-p congruence.
Yes, as far as the evidence goes. Fermat's Little Theorem is rated Empirical here: it rests on studies or measurements rather than on a saying.
Rated from two sources. 609 of the 1,116 entries carry this rating. How the scale works.
The best-known laws are the least likely to rest on measurement.
Stated by Pierre de Fermat in a 1640 letter to Frénicle de Bessy without proof, with the first published proof given by Leonhard Euler in 1736 and generalised by Euler's theorem.
9 languages, as recorded on Wikidata. These are names the idea already goes by, not translations we made. The whole index by language.
Everything above traces to en.wikipedia.org and mathworld.wolfram.com: two secondary sources, accounts of the original rather than the original itself, which has not been located for this entry. Nothing is written from memory, and the method is written down. Spot an error or a better source? Suggest a fix.