Skip to main content

soniabalan
29th January 2025

The big journey to Fermat’s little theorem

Learn about Pierre de Fermat’s Little Theorem, a result in number theory which simplicity masks profound implications across mathematics
Categories:
TLDR
The big journey to Fermat’s little theorem
Credit: Wiki Commons

History

The 17th-century mathematician Pierre de Fermat is remembered for a statement that puzzled experts for 300 years. This famous problem, known as Fermat’s Last Theorem, involves a claim about number theory that Fermat jotted in the margin of his copy of Arithmetica by Diophantus. Besides his theorem, he wrote: “I have discovered a truly remarkable proof which this margin is too small to contain”. Fermat’s son later published this book with his notes, and Fermat’s Last Theorem became legendary. It wasn’t until 1994 that mathematician Andrew Wiles proved the 3-century-old conjecture, that there are no integers (i.e. there does not exist a, b, c) that satisfy aⁿ + bⁿ = cⁿ for any integer n greater than 2. Fermat’s legacy thus endures, inspiring movies, books, and lectures.

Yet Fermat’s lesser-known but elegant Little Theorem—technically not explicitly stated in his known works—has captivated mathematicians for its simplicity and applications across areas like abstract algebra.

The Letters

Imagine early 17th-century France: you’re Marin Mersenne, a mathematics professor in Paris, and you receive a letter from a provincial lawyer, Pierre de Fermat, questioning Galileo’s ideas on free fall and posing two challenging problems for Parisian mathematicians to solve.

This lawyer, Fermat, had few published works in his lifetime, and much of what he’s known for survives in his letters with other mathematicians. Fermat’s correspondence, often sharing statements of problems he claimed to have solved, led to significant developments, including the foundations of probability theory in his letters with Blaise Pascal. Despite occasional rivalries, such as one with Descartes, Fermat’s ideas ultimately contributed to optics through his discovery of the principle that “light follows the shortest possible path.”

However, Fermat loved number theory most, though he struggled to find others with the same passion. Fellow mathematician Frenicle de Bessy shared this interest, though he grew frustrated with Fermat’s seemingly “impossible” challenges. Fermat’s Little Theorem originates in one such exchange.

On October 18, 1640, Fermat wrote to de Bessy claiming:

“Without exception, every prime number divides one of the powers -1 of any progression whatever, and the exponent of the said power is a submultiple of the given prime number -1. Also, after one has found the first power that satisfies the problem, all those of which the exponents are multiples of the exponent of the first will similarly satisfy the problem. This problem is generally true for all series and for all prime numbers; I would send you a demonstration of it, if I did not fear going on too long”.

Unpacking this statement, Fermat makes a claim relating prime numbers and terms of any geometric sequence. A prime number is a number whose only divisors are 1 and itself; think of 2, 3, 7, and 97. A geometric sequence is a sequence of numbers such that the ratio between consecutive terms is constant. It basically has the form a, a², a³,… A sequence term is aᵗ, with t known as the exponent. Fermat claims that for every prime number p, and a geometric sequence that we will denote by [a, a², a³,… ], an exponent t exists such that aᵗ-1 is divisible by p.

Now the question is, what is the relation between p and t? For now, Fermat claimed that the smallest such t is a multiple of p – 1. That means that t is either p – 1 or 2(p-1) , and so on. Moreover, Fermat added, this p also divides a²ᵗ – 1, a³ᵗ – 1, a⁴ᵗ – 1.

Fermat did not follow up this claim with proof, but provided a numerical example with a table that looked like this:

Table illustrating the different cases for trivial values of n
Credit: Sonia Balan

He illustrated the case when our geometric sequence is 3, 3², 3³,…

For any prime number p, and a natural number a,

there exists a number such that p/aᵗ − 1

The smallest such t is a factor or p − 1.

Moreover,
For all natural numbers n, p/atn-1

The claim is true, for example, in the case when p is 5. For p=5, we can find an exponent, 4, such that 34-1 is divisible by 5.

It is perhaps strange that Fermat omitted from his letter the condition that p does not divide a, maybe he assumed it was too obvious that it would fail in this case to even warrant mention. For example, if a is 6 and our chosen p is 3, then there is no exponent t such that 6ᵗ -1 is divisible by 3 since 1 is subtracted.

How the little theorem came to be

In this way, Fermat’s work in number theory led him to explore the fascinating world of prime numbers. His letters with Marin Mersenne began unexpectedly – with Fermat critiquing Galileo’s theory of free fall, despite Fermat claiming he is not particularly interested in the study of mathematical applications. However, over time, their conversations turned to more theoretic numbers and they both developed an interest in ‘perfect’ numbers.

Perfect numbers are special numbers which are the sum of all their divisors (excluding themselves). For example, the divisors of 6, excluding 6, are 1, 2, and 3, and their sum is 6. Two thousand years earlier, Euclid had already shown that if 2n-1 is prime, then the number 2n-1(2ⁿ-1) is a perfect number. Fermat and Mersenne were particularly interested in primes which can be written in the form 2n-1. Such numbers are today known as Mersenne primes, and the search for them continues.

In 1640, Fermat wrote to Mersenne presenting “three propositions I have found on which I hope to erect a great building”

  • If n is composite (ie., not prime), then 2ⁿ-1 will always be a composite number.
  • Numbers of the form 2ᴾ-2 have 2p as a factor.
  • If q is prime, then a prime factor of 2q -1 can be written as the form 2kq+1, where k is some integer.

The first statement suggests that if 2ⁿ-1 is a prime number, then n itself must be a prime number. This holds true even today, as seen with the discovery of the largest Mersenne prime, 2¹³⁶²⁷⁹⁸⁴¹ -1 in 2024.

Interestingly, the second statement is a particular case of what is known today as Fermat’s Little Theorem! Fermat’s Little Theorem can be written as such:

“For any integer a and a prime number p, the number ap-1-1 will always be divisible by p. There is an alternative way to write this, that aᴾ -a will always be divisible by p.”

If p is a prime number, then for any integer a,

if a is not divisible by p,

then ap-1-1 is divisible by p.
Or, alternatively,

aᴾ-a will always be divisible by p.

Fermat’s second proposition is, in fact, the case when a is 2, so 2ᴾ-2 is divisible by p.

Recapping Fermat’s earliest claim related to the relation between geometric sequences and prime numbers:

“For every prime number p, there exists a t such that at-1 is divisible by p. Moreover, the smallest such t is a factor of p-1“.

Comparing it to Fermat’s Little Theorem above, we realise that the smallest such t is equal to p-1.

In this way, Fermat’s early work laid the foundation for many of the mathematical theories we use today. It has proven to be highly useful in algebra and serves as a fundamental concept in encryption and cybersecurity.


More Coverage

While it is frequently seen as merely a productivity issue, it may actually be driven by deeper emotional and cognitive mechanisms
Streptococcus pneumoniae is becoming increasingly difficult to kill due to its acquired multi-drug resistance, while it claims millions of lives each year. Thankfully, oysters may hold the key for new therapeutics
The name “laptop” suggests that these devices are meant to be used on our laps, but did you know that doing so could be harmful to your health?
Science is supposed to be about truth – but for too long, the truth about many brilliant women has been buried, stolen, or ignored. International Women’s Day was first celebrated in 1911, inspired by the work of thousands of suffragists who strived to ensure more rights for women, including the one to vote