try ai
Popular Science
Edit
Share
Feedback
  • Fermat Numbers

Fermat Numbers

SciencePediaSciencePedia
Key Takeaways
  • Fermat numbers, defined as Fn=22n+1F_n = 2^{2^n} + 1Fn​=22n+1, were conjectured to be universally prime, but this was disproven by Leonhard Euler who factored F5F_5F5​.
  • Any two distinct Fermat numbers are relatively prime, a property that elegantly proves the existence of an infinite number of primes.
  • The Gauss–Wantzel theorem states a regular polygon is constructible with a straightedge and compass only if its number of sides is a power of two multiplied by distinct Fermat primes.
  • Specific primality tests like Pépin's Test exist for Fermat numbers, and their potential prime factors are restricted to the form k⋅2n+1+1k \cdot 2^{n+1} + 1k⋅2n+1+1.

Introduction

In the vast landscape of number theory, certain sequences of integers stand out for their simplicity, elegance, and the profound questions they pose. Among the most famous of these are the Fermat numbers, generated by the simple formula Fn=22n+1F_n = 2^{2^n} + 1Fn​=22n+1. First studied by the great 17th-century mathematician Pierre de Fermat, these numbers initially seemed to offer a direct path to an infinite family of primes. However, this seemingly straightforward sequence holds deep complexities and has led mathematicians on a centuries-long journey of discovery, disappointment, and unexpected connections. This article delves into the fascinating world of Fermat numbers, addressing the gap between their simple definition and their complex behavior. We will explore their fundamental structure, the dramatic history of the conjecture about their primality, and their surprising influence in fields far beyond pure mathematics.

The first part of our exploration, ​​Principles and Mechanisms​​, will uncover the core properties of Fermat numbers, from their astonishing growth rate to an elegant recursive identity that proves any two are relatively prime. We will recount the story of how Leonhard Euler shattered Fermat's original conjecture and examine the powerful tools, like Pépin's Test, used to analyze their primality. Following this, the ​​Applications and Interdisciplinary Connections​​ section will reveal how these abstract numbers provide the key to a 2,000-year-old problem in geometry and play a foundational role in the story of modern cryptographic primality testing. Let's begin by examining the building blocks of these remarkable integers.

Principles and Mechanisms

So, we have met these curious numbers, the Fermat numbers, born from a beautifully simple formula: Fn=22n+1F_n = 2^{2^n} + 1Fn​=22n+1. At first glance, they might seem like a mere mathematical curiosity, a sequence generated by stacking exponents. But if we roll up our sleeves and begin to play with them, we discover a world of unexpected structure, elegant properties, and profound mysteries that have captivated mathematicians for centuries. Let’s embark on a journey to understand what makes these numbers tick.

The Anatomy of a Fermat Number

Let's start by getting our hands dirty. The definition involves a "double exponent," which makes these numbers grow at a truly astonishing rate. Let’s write out the first few:

  • n=0n=0n=0: F0=220+1=21+1=3F_0 = 2^{2^0} + 1 = 2^1 + 1 = 3F0​=220+1=21+1=3
  • n=1n=1n=1: F1=221+1=22+1=5F_1 = 2^{2^1} + 1 = 2^2 + 1 = 5F1​=221+1=22+1=5
  • n=2n=2n=2: F2=222+1=24+1=17F_2 = 2^{2^2} + 1 = 2^4 + 1 = 17F2​=222+1=24+1=17
  • n=3n=3n=3: F3=223+1=28+1=257F_3 = 2^{2^3} + 1 = 2^8 + 1 = 257F3​=223+1=28+1=257
  • n=4n=4n=4: F4=224+1=216+1=65537F_4 = 2^{2^4} + 1 = 2^{16} + 1 = 65537F4​=224+1=216+1=65537

Notice something remarkable? All five of these numbers—3, 5, 17, 257, and 65537—are prime. It seems we’ve stumbled upon a prime-generating machine! This is precisely what the great Pierre de Fermat himself thought in the 17th century. But before we get carried away, let's appreciate the sheer size of these numbers.

The growth is not merely exponential, like 2n2^n2n; it is ​​doubly exponential​​. What does this mean? For an exponential sequence like the Mersenne numbers, Mn=2n−1M_n = 2^n - 1Mn​=2n−1, taking the logarithm gives something proportional to nnn: ln⁡(Mn)∼nln⁡2\ln(M_n) \sim n \ln 2ln(Mn​)∼nln2. The growth is steady and predictable. But for Fermat numbers, the logarithm of FnF_nFn​ grows exponentially: ln⁡(Fn)∼2nln⁡2\ln(F_n) \sim 2^n \ln 2ln(Fn​)∼2nln2. Each step in the sequence represents a monumental leap in magnitude. F5F_5F5​ is already over four billion. F6F_6F6​ has 20 digits. The number of digits in F30F_{30}F30​ would be more than 300 million! This explosive growth is a crucial clue in the story of Fermat numbers; their immense size makes them incredibly difficult to work with, and, as we'll see, gives them plenty of "room" to be composite.

A Surprising Family Connection

You might think that these numbers, separated by such vast gulfs, would have little to do with one another. But Nature has a funny way of connecting things. Let’s try a little experiment. What happens if we multiply the first few Fermat numbers together?

F0=3F_0 = 3F0​=3

F0⋅F1=3⋅5=15F_0 \cdot F_1 = 3 \cdot 5 = 15F0​⋅F1​=3⋅5=15

F0⋅F1⋅F2=15⋅17=255F_0 \cdot F_1 \cdot F_2 = 15 \cdot 17 = 255F0​⋅F1​⋅F2​=15⋅17=255

Do these results look familiar? They are all one less than a power of two. In fact, they are one less than the next Fermat number in the sequence!

F1−2=5−2=3=F0F_1 - 2 = 5 - 2 = 3 = F_0F1​−2=5−2=3=F0​

F2−2=17−2=15=F0⋅F1F_2 - 2 = 17 - 2 = 15 = F_0 \cdot F_1F2​−2=17−2=15=F0​⋅F1​

F3−2=257−2=255=F0⋅F1⋅F2F_3 - 2 = 257 - 2 = 255 = F_0 \cdot F_1 \cdot F_2F3​−2=257−2=255=F0​⋅F1​⋅F2​

This pattern holds true for all nnn. It is a beautiful, recursive identity:

∏k=0n−1Fk=Fn−2\prod_{k=0}^{n-1} F_k = F_n - 2∏k=0n−1​Fk​=Fn​−2

The proof is a delightful cascade of the simplest algebraic identity: (x−1)(x+1)=x2−1(x-1)(x+1) = x^2-1(x−1)(x+1)=x2−1. Starting with F0=220+1F_0 = 2^{2^0}+1F0​=220+1, we see that (F0−1)F0=(2−1)(2+1)=22−1(F_0 - 1)F_0 = (2-1)(2+1) = 2^2 - 1(F0​−1)F0​=(2−1)(2+1)=22−1. Then (22−1)F1=(22−1)(22+1)=24−1(2^2-1)F_1 = (2^2-1)(2^2+1) = 2^4-1(22−1)F1​=(22−1)(22+1)=24−1. This telescoping product continues perfectly, giving us ∏k=0n−1Fk=22n−1\prod_{k=0}^{n-1} F_k = 2^{2^n} - 1∏k=0n−1​Fk​=22n−1, which is exactly Fn−2F_n - 2Fn​−2.

This elegant connection has a stunning and profound consequence. ​​Any two distinct Fermat numbers are relatively prime​​; that is, they share no common factors other than 1. The proof is wonderfully simple. Suppose a prime number ppp divides both FmF_mFm​ and FnF_nFn​, with m<nm \lt nm<n. Since ppp divides FmF_mFm​, it must also divide the product ∏k=0n−1Fk\prod_{k=0}^{n-1} F_k∏k=0n−1​Fk​. From our identity, this product is equal to Fn−2F_n - 2Fn​−2. So, our prime ppp must divide both FnF_nFn​ and Fn−2F_n - 2Fn​−2. If a number divides two integers, it must also divide their difference. Here, the difference is just Fn−(Fn−2)=2F_n - (F_n-2) = 2Fn​−(Fn​−2)=2. This means the only possible prime factor our two Fermat numbers could share is 2. But every Fermat number Fn=22n+1F_n = 2^{2^n} + 1Fn​=22n+1 is clearly odd. So, no two Fermat numbers can share a common prime factor. They are perfectly, pairwise coprime.

As an aside, this property alone provides one of the most elegant proofs for the infinitude of primes! Since each FnF_nFn​ has a prime factor, and since all these prime factors must be distinct from one another, there must be an infinite number of primes. A truly remarkable result from a simple family of numbers.

The Rise and Fall of a Grand Conjecture

Armed with the observation that F0,F1,F2,F3,F_0, F_1, F_2, F_3,F0​,F1​,F2​,F3​, and F4F_4F4​ are all prime, Fermat conjectured that all FnF_nFn​ are prime. For over a century, this conjecture stood as a tantalizing possibility. The next number in the sequence, F5=232+1F_5 = 2^{32} + 1F5​=232+1, is enormous: 4,294,967,2974,294,967,2974,294,967,297. How could one possibly determine if such a behemoth is prime in an age without computers?

This is where the genius of Leonhard Euler enters the story. Euler didn't just try to divide F5F_5F5​ by every prime. He used theory to constrain the search. He proved a crucial theorem that acts as a powerful sieve: ​​any prime factor ppp of a Fermat number FnF_nFn​ must be of the form p=k⋅2n+1+1p = k \cdot 2^{n+1} + 1p=k⋅2n+1+1 for some integer kkk​​.

Let's see what this means for F5F_5F5​. Here, n=5n=5n=5, so any prime factor must be of the form p=k⋅26+1=64k+1p = k \cdot 2^{6} + 1 = 64k + 1p=k⋅26+1=64k+1. This drastically narrows the search! We don't need to check primes like 3, 5, 7, 11, etc. We only need to check primes of the form 64k+164k+164k+1, such as 193, 257, 449, ... and 641 (for k=10k=10k=10).

Euler tested 641 and found that it was indeed a factor, shattering Fermat's conjecture. His proof of this fact is a masterpiece of elegance that avoids any messy long division. He simply observed two things about the number 641:

  1. 641=640+1=5⋅128+1=5⋅27+1641 = 640 + 1 = 5 \cdot 128 + 1 = 5 \cdot 2^7 + 1641=640+1=5⋅128+1=5⋅27+1. This means 5⋅27≡−1(mod641)5 \cdot 2^7 \equiv -1 \pmod{641}5⋅27≡−1(mod641).
  2. 641=625+16=54+24641 = 625 + 16 = 5^4 + 2^4641=625+16=54+24. This means 54≡−24(mod641)5^4 \equiv -2^4 \pmod{641}54≡−24(mod641).

Now watch the magic. Take the first congruence and raise it to the fourth power: (5⋅27)4≡(−1)4(mod641)  ⟹  54⋅228≡1(mod641)(5 \cdot 2^7)^4 \equiv (-1)^4 \pmod{641} \implies 5^4 \cdot 2^{28} \equiv 1 \pmod{641}(5⋅27)4≡(−1)4(mod641)⟹54⋅228≡1(mod641) Now, substitute the second congruence into this result: (−24)⋅228≡1(mod641)  ⟹  −232≡1(mod641)(-2^4) \cdot 2^{28} \equiv 1 \pmod{641} \implies -2^{32} \equiv 1 \pmod{641}(−24)⋅228≡1(mod641)⟹−232≡1(mod641) Multiplying by −1-1−1, we get 232≡−1(mod641)2^{32} \equiv -1 \pmod{641}232≡−1(mod641), which is the same as saying 232+1≡0(mod641)2^{32} + 1 \equiv 0 \pmod{641}232+1≡0(mod641). And there it is! 641641641 divides F5F_5F5​. The grand conjecture had fallen. To this day, no other Fermat primes beyond F4F_4F4​ have been discovered, and many subsequent Fermat numbers have been proven composite.

A Prime's Litmus Test

Euler's method showed us how to find factors by restricting the possibilities. But what if we want to go the other way? How can we prove a Fermat number is prime? It turns out there is a wonderfully specific and efficient primality test just for them, known as ​​Pépin's Test​​. It states that for n≥1n \ge 1n≥1, the Fermat number FnF_nFn​ is prime if and only if:

3(Fn−1)/2≡−1(modFn)3^{(F_n - 1)/2} \equiv -1 \pmod{F_n}3(Fn​−1)/2≡−1(modFn​)

This is a definitive litmus test. If the congruence holds, FnF_nFn​ is prime. If it doesn't, FnF_nFn​ is composite. Let's test it on the numbers we know are prime.

For F1=5F_1 = 5F1​=5, the test requires us to compute 3(5−1)/2(mod5)3^{(5-1)/2} \pmod 53(5−1)/2(mod5). This simplifies to 32(mod5)3^2 \pmod 532(mod5), which is 9(mod5)9 \pmod 59(mod5). The remainder is 4. And since −1≡4(mod5)-1 \equiv 4 \pmod 5−1≡4(mod5), the test works perfectly! F1F_1F1​ is prime.

For F2=17F_2 = 17F2​=17, we must compute 3(17−1)/2(mod17)3^{(17-1)/2} \pmod{17}3(17−1)/2(mod17), which is 38(mod17)3^8 \pmod{17}38(mod17). The exponent is larger, but we can handle it efficiently using modular exponentiation (repeated squaring):

  • 31≡3(mod17)3^1 \equiv 3 \pmod{17}31≡3(mod17)
  • 32≡32=9(mod17)3^2 \equiv 3^2 = 9 \pmod{17}32≡32=9(mod17)
  • 34≡92=81≡13(mod17)3^4 \equiv 9^2 = 81 \equiv 13 \pmod{17}34≡92=81≡13(mod17)
  • 38≡132=169≡16(mod17)3^8 \equiv 13^2 = 169 \equiv 16 \pmod{17}38≡132=169≡16(mod17)

And since 16≡−1(mod17)16 \equiv -1 \pmod{17}16≡−1(mod17), the test passes again, confirming that F2=17F_2=17F2​=17 is prime. This powerful tool allows us to certify primality for these special numbers, a task that is generally much harder than finding factors.

A Probabilistic Post-Mortem: Why We Expect Finitude

The fall of Fermat's conjecture leaves us with a deep question: Are there any more Fermat primes, or are F0F_0F0​ through F4F_4F4​ the only ones? No one knows for sure, but the mathematical community has a strong suspicion, a heuristic expectation, that there are only a finite number of them. Why? The reasoning is a beautiful blend of probability theory and number theory.

The first argument comes from the ​​Prime Number Theorem​​, which tells us that the "probability" of a randomly chosen large integer NNN being prime is roughly 1/ln⁡(N)1/\ln(N)1/ln(N). We already saw that FnF_nFn​ grows doubly exponentially, so its logarithm, ln⁡(Fn)\ln(F_n)ln(Fn​), grows exponentially. The sum of these probabilities over all nnn looks like ∑nC/2n\sum_n C/2^n∑n​C/2n for some constant CCC. This is a geometric series that converges to a finite value. In the language of probability, this suggests that the "event" of FnF_nFn​ being prime should only happen a finite number of times.

The second argument is even more compelling. It builds on Euler's insight. Not only is FnF_nFn​ an enormous number, but any prime factor it might have is severely restricted. A prime factor must belong to the very sparse set of primes of the form k⋅2n+1+1k \cdot 2^{n+1} + 1k⋅2n+1+1. As nnn grows, FnF_nFn​ becomes an astronomically large target, while the primes that are "allowed" to be its factors become increasingly rare. It seems almost inevitable that for large nnn, one of these specially-formed primes will land a "hit" and be a factor of FnF_nFn​. The deck is stacked against primality.

So we are left with a mystery. The first five Fermat numbers are prime, but the universe of numbers that follow seem to be universally composite. These numbers, which began as a simple pattern of exponents, have led us through elegant identities, dramatic historical discoveries, powerful computational tools, and finally to the frontiers of mathematical conjecture, where even today, the simplest questions can remain tantalizingly out of reach.

Applications and Interdisciplinary Connections

After exploring the internal world of Fermat numbers—their definition, their peculiar properties, and the mystery of their primality—one might be tempted to ask, "What are they good for?" It is a fair question. Often in mathematics, a concept is studied for its own intrinsic beauty, and its applications are discovered much later, sometimes in the most unexpected of places. This is precisely the story of Fermat numbers. They are not merely a historical curiosity or a playground for number theorists. Instead, they serve as a crucial connecting thread, weaving together the ancient art of geometry, the modern science of computation, and the deepest questions about the nature of prime numbers themselves. Let us embark on a journey to see where these remarkable numbers appear on the grand map of science.

The Geometry of Primes: Constructing the World with a Compass

For over two thousand years, one of the great unsolved problems of geometry, handed down from the ancient Greeks, was to determine exactly which regular polygons—shapes with equal sides and equal angles—could be constructed using only the simplest of tools: an unmarked straightedge and a compass. The Greeks knew how to construct a triangle (n=3n=3n=3), a square (n=4n=4n=4), a pentagon (n=5n=5n=5), and a hexagon (n=6n=6n=6). They also knew that if you can construct an nnn-gon, you can bisect its angles to construct a 2n2n2n-gon. This means that polygons with n=2k⋅3n=2^k \cdot 3n=2k⋅3 or n=2k⋅5n=2^k \cdot 5n=2k⋅5 sides were all constructible. But what about a 7-sided polygon (a heptagon)? Or a 9-sided one (a nonagon)? Despite centuries of effort, no one could find a construction for these, and no one could prove it was impossible. The problem lay dormant, a ghost in the geometric machine.

The silence was broken in 1796 by a 19-year-old prodigy, Carl Friedrich Gauss. In a breathtaking display of genius, he proved that a regular 17-gon was constructible. This was the first major advance on the problem in two millennia. But Gauss did much more than that. He unearthed a profound and utterly unexpected connection between this tangible, geometric problem and the abstract world of number theory. The complete answer, later finalized by Pierre Wantzel, is a theorem that feels like it was pulled from a different universe.

The Gauss–Wantzel theorem states that a regular nnn-gon is constructible if and only if the number of sides, nnn, is the product of a power of 2 and any number of distinct Fermat primes.

Suddenly, the five known prime Fermat numbers—3,5,17,257,655373, 5, 17, 257, 655373,5,17,257,65537—were no longer just numerical curiosities. They were the gatekeepers of geometric possibility. A triangle (n=3n=3n=3) is constructible. A pentagon (n=5n=5n=5) is constructible. Gauss's famous 17-gon is constructible. But a heptagon (n=7n=7n=7) is not, because 7 is not a Fermat prime. A nonagon (n=9=32n=9=3^2n=9=32) is not, because the odd prime factors must be distinct; you can't use the same Fermat prime twice.

The bridge between geometry and Fermat numbers is built from the language of abstract algebra. The core idea is that a geometric length is "constructible" only if the number associated with it can be reached from the rational numbers through a series of square roots. This implies that the "degree" of the number, in a technical sense, must be a power of 2. For a regular nnn-gon, this degree is related to Euler's totient function, φ(n)\varphi(n)φ(n). The condition for constructibility boils down to requiring that φ(n)\varphi(n)φ(n) be a power of 2. And when does this happen? It happens precisely when nnn is of the form n=2kp1p2⋯pmn = 2^k p_1 p_2 \cdots p_mn=2kp1​p2​⋯pm​, where the pip_ipi​ are distinct odd primes such that pi−1p_i-1pi​−1 is a power of 2. A beautiful little piece of number theory then shows that any prime ppp where p−1p-1p−1 is a power of 2 must, in fact, be a Fermat prime. The chain of logic is complete, linking the physical act of drawing to the deepest structure of numbers.

This theorem allows us to find all sorts of constructible polygons. A 30-gon (30=2⋅3⋅530 = 2 \cdot 3 \cdot 530=2⋅3⋅5) is constructible, as is a 51-gon (51=3⋅1751 = 3 \cdot 1751=3⋅17). The smallest odd composite number of sides for a constructible polygon is n=3×5=15n = 3 \times 5 = 15n=3×5=15. Yet, these numbers are rare. In the range from n=3n=3n=3 to n=1000n=1000n=1000, there are only 52 such integers that allow for a perfect construction. This scarcity highlights just how special the Fermat primes are. They are the only primes allowed to be the building blocks for the odd-sided polygons in Euclid's world.

The Digital Search for Primes: Fermat's Legacy in Cryptography

Let's leap forward from the world of classical geometry to our modern digital age, an era built upon the foundations of cryptography. Many modern cryptographic systems, like RSA, rely on the difficulty of factoring very large numbers. To create these systems, we first need a way to find very large prime numbers. How can you be sure a 300-digit number is prime? Trying to divide it by every number smaller than it would take longer than the age of the universe.

Here, another of Fermat's contributions enters the stage: Fermat's Little Theorem. It states that if ppp is a prime number, then for any integer aaa not divisible by ppp, the congruence ap−1≡1(modp)a^{p-1} \equiv 1 \pmod{p}ap−1≡1(modp) must hold. This gives us a brilliant idea for a primality test. To test a large number nnn, we can pick a random base aaa, calculate an−1(modn)a^{n-1} \pmod nan−1(modn), and see if the result is 1. If it's not 1, we know with absolute certainty that nnn is composite.

But what if the result is 1? Can we conclude that nnn is prime? Unfortunately, no. Composite numbers that masquerade as primes by satisfying the congruence an−1≡1(modn)a^{n-1} \equiv 1 \pmod nan−1≡1(modn) for some base aaa are called ​​Fermat pseudoprimes​​ to base aaa. They are "liars" that fool this simple test.

This is where the story gets worse. Are there composite numbers that are so good at lying that they pass the test for every possible base aaa that is coprime to them? The unfortunate answer is yes. These ultimate impostors are called ​​Carmichael numbers​​. The smallest is 561=3⋅11⋅17561 = 3 \cdot 11 \cdot 17561=3⋅11⋅17. For this number, a560≡1(mod561)a^{560} \equiv 1 \pmod{561}a560≡1(mod561) for all integers aaa that don't share a factor with 561.

The existence of even one Carmichael number is a devastating blow to the simple Fermat test. It means that no matter how many different coprime bases you test, a Carmichael number will pass every single time. The test will always return "probably prime," giving you a completely false sense of security. The strategy of just trying more bases to reduce the error probability to zero completely fails.

For a long time, it was hoped that Carmichael numbers were rare oddities. Perhaps there were only a finite number of them, which we could list and check for explicitly. However, in 1994, it was proven that there are ​​infinitely many​​ Carmichael numbers. This result was the final nail in the coffin for the simple Fermat test as a reliable, general-purpose primality algorithm. For any security threshold you desire, there is a composite Carmichael number larger than it, waiting to fool your test.

This tale of failure is, paradoxically, a story of progress. The deep flaws in the Fermat test, embodied by the existence of infinitely many Carmichael numbers, forced mathematicians and computer scientists to develop more sophisticated tools. This led to stronger probabilistic tests like the Miller-Rabin test, which are the industrial-strength algorithms used today to find the gigantic primes that secure our digital communications. In a sense, the intellectual descendants of Fermat's work on primality helped us understand the limits of his own test, paving the way for the robust cryptography we rely on daily.

A Deeper Look: The Anatomy of a Fermat Number

We've seen Fermat numbers as gatekeepers in geometry and their namesake theorem as a flawed but foundational concept in cryptography. Let's now turn the microscope back onto the Fermat numbers themselves. Fermat conjectured that all numbers of the form Fn=22n+1F_n = 2^{2^n}+1Fn​=22n+1 are prime. He checked F0=3F_0=3F0​=3, F1=5F_1=5F1​=5, F2=17F_2=17F2​=17, F3=257F_3=257F3​=257, and F4=65537F_4=65537F4​=65537, and found them all to be prime. But his conjecture was wrong. In 1732, Leonhard Euler showed that the next one, F5F_5F5​, is composite:

F5=232+1=4,294,967,297=641×6,700,417F_5 = 2^{32} + 1 = 4,294,967,297 = 641 \times 6,700,417F5​=232+1=4,294,967,297=641×6,700,417

Since Euler's time, no other Fermat primes have been found. Many more Fermat numbers have been factored, but the question of whether there are any more Fermat primes beyond F4F_4F4​ remains one of the great unsolved problems in number theory.

How does one even begin to check if a number like F20=2220+1F_{20} = 2^{2^{20}}+1F20​=2220+1, which has over 300,000 digits, is prime? A brute-force search for factors is computationally absurd. The key is to find a hidden structure, a property that any potential factor must have. Such a property exists, and it is a thing of beauty.

It can be proven that any prime factor ppp of a Fermat number Fn=22n+1F_n = 2^{2^n}+1Fn​=22n+1 must be of the form p=k⋅2n+1+1p = k \cdot 2^{n+1} + 1p=k⋅2n+1+1 for some integer kkk.

The proof is remarkably elegant. If a prime ppp divides FnF_nFn​, then 22n+1≡0(modp)2^{2^n}+1 \equiv 0 \pmod p22n+1≡0(modp), or 22n≡−1(modp)2^{2^n} \equiv -1 \pmod p22n≡−1(modp). If we square both sides, we get (22n)2≡(−1)2(modp)(2^{2^n})^2 \equiv (-1)^2 \pmod p(22n)2≡(−1)2(modp), which is 22n+1≡1(modp)2^{2^{n+1}} \equiv 1 \pmod p22n+1≡1(modp). This means the multiplicative order of 2 modulo ppp—the smallest positive power ddd such that 2d≡1(modp)2^d \equiv 1 \pmod p2d≡1(modp)—must divide 2n+12^{n+1}2n+1. But since 22n≡−1(modp)2^{2^n} \equiv -1 \pmod p22n≡−1(modp), the order cannot be 2n2^n2n or any smaller power of 2. The only possibility left is that the order is exactly 2n+12^{n+1}2n+1. Finally, by Fermat's Little Theorem, we know this order must divide p−1p-1p−1. And so, 2n+12^{n+1}2n+1 must divide p−1p-1p−1, which is the same as saying ppp must be of the form k⋅2n+1+1k \cdot 2^{n+1} + 1k⋅2n+1+1.

This is an incredibly powerful result. For Euler's example of F5F_5F5​, any prime factor must be of the form p=k⋅26+1=64k+1p = k \cdot 2^6 + 1 = 64k+1p=k⋅26+1=64k+1. Instead of testing all primes, we only need to test primes of this special form: 193,257,449,577,641,…193, 257, 449, 577, 641, \dots193,257,449,577,641,…. And sure enough, the fifth one on the list, 641, is a factor. This shortcut transforms an impossible task into a feasible (though still difficult) computation, and it forms the basis of specialized algorithms for factoring Fermat numbers.

From the geometry of the ancient Greeks to the cryptographic needs of the internet, and into the deep, unsolved mysteries of their own primality, Fermat numbers stand as a testament to the interconnectedness of mathematics. They show us that sometimes, the most abstract questions can have the most concrete consequences, and that a simple pattern can resonate across disciplines, creating a beautiful and unexpected harmony.