Vol. I a living index of named laws · est. mmxxvi no ads · no account
The Law Tomeindex of named laws
Often confused

Fermat's Little Theorem vs Fermat's Last Theorem

These two are routinely mistaken for each other. Here is what separates them, and what each actually claims, field by field.

Fermat's Little Theorem compared with Fermat's Last Theorem
AttributeFermat's Little TheoremFermat's Last Theorem
FieldMathematics & proofMathematics & proof
ReliabilityEmpiricalEmpirical
Coined16401637
Named afterPierre de FermatPierre de Fermat
TypeEstablishedEstablished

What they have in common

  • Both sit in Mathematics & proof.
  • Both are rated Empirical, so they stand on the same kind of evidence.
  • Fermat's Last Theorem is the older of the two by 3 years.

Side by side

What it claims

Fermat's Little TheoremFor 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 Last TheoremNo three positive whole numbers can satisfy a to the n plus b to the n equals c to the n for any power above two.

In plain English

Fermat's Little TheoremFermat'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.
Fermat's Last TheoremFermat's Last Theorem states that no three positive integers a, b, and c can satisfy the equation a to the power n plus b to the power n equals c to the power n whenever the exponent n is an integer greater than two. For the exponent two the equation is just the Pythagorean relation, which has infinitely many whole-number solutions, the Pythagorean triples like three, four, five. Fermat's claim is that this abundance vanishes the moment the power exceeds two: no solutions exist at all. Scrawled by Pierre de Fermat around 1637 in the margin of a book, alongside the tantalising note that he had a marvellous proof too large to fit, it became the most famous unsolved problem in mathematics, resisting proof for over three hundred and fifty years.

How it works

Fermat's Little TheoremThe 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.
Fermat's Last TheoremThe difficulty is that a single clean statement conceals infinitely many separate cases, one for each exponent, and no elementary method dispatches them all. Progress came case by case: Fermat himself proved the exponent four using his method of infinite descent, Euler settled the cube, and Sophie Germain, Dirichlet, Legendre, and Kummer extended the range with ever deeper number theory, Kummer covering all so-called regular primes with his theory of ideal numbers. It suffices to prove the theorem for the exponent four and for every odd prime, since any other exponent shares a factor with one of these. The final proof came from an unexpected direction: Andrew Wiles proved that certain elliptic curves are modular, which by Ribet's theorem forces a solution to Fermat's equation to be impossible.

Why it matters

Fermat's Little TheoremFermat'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.
Fermat's Last TheoremFermat's Last Theorem is the most celebrated problem in the history of mathematics, a deceptively simple statement whose three-and-a-half-century resistance drove the development of algebraic number theory, from Kummer's ideal numbers to the modern machinery of elliptic curves, modular forms, and Galois representations. Wiles's 1995 proof is a landmark of twentieth-century mathematics, uniting fields that had seemed distant and vindicating decades of work on the modularity conjecture. Wiles received the Abel Prize in 2016 for the achievement. The saga is also a lesson in mathematical humility, since Fermat's own claimed proof was almost certainly mistaken, given that the eventual proof used tools centuries beyond his reach.

Where it breaks down

Fermat's Little TheoremThe 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 Last TheoremThe theorem is specific to exponents greater than two and to positive integers; the exponent two has infinitely many solutions, and allowing zero or non-integer values changes everything. Fermat's own marginal claim of a proof is not part of the established result and is generally regarded as unfounded, since no elementary proof is known and the accepted proof relies on twentieth-century mathematics far beyond his tools. The proof, while complete and checked, is long and highly technical, so the theorem is easy to state but understood in full by relatively few, and it settles a single equation rather than a broad family, its depth lying in the methods it required.

Commonly misread as

Fermat's Little TheoremFermat'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.
Fermat's Last TheoremThe theorem is not that the equation never balances for any exponent; for the power two it has infinitely many solutions, the Pythagorean triples, and the claim is only about powers above two. Fermat almost certainly did not possess a valid general proof, so his margin note is a historical curiosity, not evidence. And Wiles's proof does not exhibit or rule out particular numbers by search; it argues indirectly that any solution would contradict the modularity of elliptic curves, an impossibility, so the theorem holds for all exponents above two at once.

A worked example

Fermat's Little TheoremIf a to the power p minus one is not congruent to one modulo p for some a, then p is definitely composite, the basis of the Fermat primality test.
Fermat's Last TheoremOn 9 November 2026 Anthropic said a team of 1,000 Claude Fable 5.2 agents formalized the proof of Fermat's Last Theorem in the Lean language in about 30 hours, starting from lemmas its first, 11-day formalization had already proved. The figures are the company's own. The theorem takes one line to state, yet checking its proof every step of the way by machine is still a job measured in days and hours.

Where it came from

Fermat's Little TheoremStated 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.
Fermat's Last TheoremConjectured by Pierre de Fermat around 1637 in a margin of Diophantus's Arithmetica, with special cases proved over centuries by Fermat, Euler, Germain, Dirichlet, and Kummer, and finally proved in full by Andrew Wiles, with Richard Taylor, in work published in 1995.

Sources

Related comparisons

Questions about this pair

What is the difference between Fermat's Little Theorem and Fermat's Last Theorem?

Fermat's Little Theorem says “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 Last Theorem says “No three positive whole numbers can satisfy a to the n plus b to the n equals c to the n for any power above two.”. They are near-twins and easy to confuse; the field-by-field comparison above sets out what each actually claims.

Are Fermat's Little Theorem and Fermat's Last Theorem the same thing?

No, though they are routinely mistaken for each other. They are recorded here as near-twins precisely because the confusion is common.

Which one should I apply?

Whichever one's conditions your case meets. This page will not guess which that is. Fermat's Little Theorem states where it stops working, and so does Fermat's Last Theorem; both passages are above, in the entries' own words. Reading the two limits side by side answers this faster than a recommendation from a site that cannot see your situation.