Fermat Number Calculator
Term
- Fermat numbers have the form 2^(2^n) + 1: the exponent is itself a power of two, so the values explode in size - each one is the product of all the previous ones, plus 2.
- For n = 3: 2^n = 8, and 2^(2^n) = 256.
- Adding 1 gives the Fermat number F(3) = 257, with 3 digits.
- Fermat hoped every such number would be prime, but F(0) to F(4) are the only known Fermat primes: F(3) here is prime. Any factor of a Fermat number F(n) must have the form k x 2^(n+2) + 1, which is how small factors are hunted.
A Fermat number calculator computes numbers of the form F(n) = 2^(2^n) + 1, where the exponent doubles at every step. Enter a value of n and the calculator returns the exact Fermat number, however large it grows. The early cases are famous: F(3) = 257 and F(4) = 65,537 are prime. Then F(5) = 4,294,967,297, which equals 641 x 6,700,417. Euler factored it about a century after Fermat claimed all such numbers were prime. F(0) through F(4) remain the only known Fermat primes, so the calculator also helps you see how quickly these numbers outgrow easy checking.
The calculator relies on a property that makes testing these numbers practical: any prime factor of F(n) must have the form k x 2^(n+2) + 1. That restriction is how Euler found 641, and it is the accepted standard for this kind of calculation because it narrows the search to a small, well-defined set of candidates instead of every possible divisor. This page shows the formula, step-by-step workings, worked examples and sources, so you can follow each stage of the calculation rather than just reading a final number.
Worked examples
F(3) = 257, prime
(3)
| Fermat number F(n) | 257 |
| The 2^(2^n) term | 256 |
| Digits in F(n) | 3 |
| Status | Prime |
F(4) = 65537, prime
(4)
| Fermat number F(n) | 65,537 |
| The 2^(2^n) term | 65,536 |
| Digits in F(n) | 5 |
| Status | Prime |
F(5), factored by Euler
(5)
| Fermat number F(n) | 4,294,967,297 |
| The 2^(2^n) term | 4,294,967,296 |
| Digits in F(n) | 10 |
| Status | Composite: 641 x 6,700,417 |
Fermat's conjecture
Fermat numbers have the form F(n) = 2^(2^n) + 1, so the exponent doubles at every step: F(0) = 3, F(1) = 5, F(2) = 17, F(3) = 257, and F(4) = 65,537. Fermat computed these first five values and found that each one was prime. F(3) = 257 and F(4) = 65,537 are prime, and so are the three smaller ones. From that run of five primes, Fermat drew a sweeping conclusion: he believed every number of this form, no matter how large n grew, would turn out to be prime.
It was a natural guess, and a costly one. The pattern held for every case he could check by hand, and the numbers grow so quickly that checking further cases was beyond him. The next one, F(5), is already 4,294,967,297, a ten-digit number. Fermat asserted that all such numbers were prime, but he did not have a proof, and the evidence he did have came from only the smallest members of the sequence.
About a century later, Leonhard Euler proved the conjecture false. He showed that F(5) = 4,294,967,297 = 641 x 6,700,417, so the sixth Fermat number is composite. Euler did not find the factor by trial division alone. He used a structural rule: any prime factor of F(n) must have the form k x 2^(n+2) + 1. For F(5), that means any prime factor must be of the form k x 128 + 1, which narrows the search enormously. Working through candidates of that shape, Euler found 641, and dividing confirmed the second factor, 6,700,417.
The collapse of Fermat's conjecture did not end the story; it opened a larger question. F(0) to F(4) remain the only known Fermat primes. Every Fermat number beyond F(4) that has been fully factored or tested has turned out to be composite, and no further Fermat prime has been found. Whether another one exists is still unknown. A fermat number calculator lets you generate these numbers and see for yourself how fast they grow, and how quickly they pass beyond anything that can be checked by hand.
The episode is a compact lesson in why a pattern seen in a handful of cases is not a proof. Fermat's five primes were real, and his rule for their form was correct. What failed was the leap from five examples to all n. Euler's factorization of F(5) stands as the correction, and the factor-form rule he used, k x 2^(n+2) + 1, remains the standard starting point for anyone hunting factors of a Fermat number today.
How fast they grow
The definition of a Fermat number, F(n) = 2^(2^n) + 1, hides how explosive the growth is. The key is that the exponent itself doubles at every step. Going from one Fermat number to the next does not add a little to the exponent — it doubles it, and then the base 2 is raised to that already-doubled power. A fermat number calculator makes this easy to see, because each result is far larger than the one before it, not by a constant factor but by a factor that keeps climbing.
The first few values stay small enough to write out and check by hand. F(3) = 257 and F(4) = 65,537 are both prime. That run of primes is what led Fermat to believe every number of this form would be prime. The pattern breaks at the very next step. F(5) = 4,294,967,297, a ten-digit number, and it is not prime: it equals 641 x 6,700,417. Euler factored it about a century after Fermat claimed all such numbers were prime.
The table below lays out these three values side by side so the jump in size is visible at a glance. Notice that the step from F(3) to F(4) multiplies the size by roughly 255, and the step from F(4) to F(5) multiplies it again by a much larger amount. Because the exponent doubles each time, the numbers do not grow in a straight line; they accelerate.
Euler did not find 641 by trial and error over every possible divisor. Any prime factor of F(n) must have the form k x 2^(n+2) + 1, and that rule is how Euler found 641. For F(5), the required form is k x 2^7 + 1, so only a restricted set of candidates needed checking. This same structure is why F(0) to F(4) remain the only known Fermat primes: as n grows, the numbers become so large that testing them is a serious computational task, and every larger case examined so far has turned out to be composite.
| Fermat number | Value | Digits | Prime? |
|---|---|---|---|
| F(3) | 257 | 3 | Yes |
| F(4) | 65,537 | 5 | Yes |
| F(5) | 4,294,967,297 = 641 x 6,700,417 | 10 | No |
Euler's factorization of F(5)
F(5) is where the story of Fermat numbers turns. Fermat numbers have the form F(n) = 2^(2^n) + 1, so the exponent doubles at every step. The first few values fit that pattern neatly: F(3) = 257 and F(4) = 65,537 are prime. Fermat himself believed every number of this form would be prime, but F(5) = 4,294,967,297 tells a different story. A fermat number calculator shows the size of the number quickly; the harder question is how anyone proved it composite before computers existed.
The key is a restriction on what a factor can look like. Any prime factor of F(n) must have the form k x 2^(n+2) + 1. For F(5), that means every prime factor must be one more than a multiple of 2^(5+2), or 128. So instead of testing every prime up to the square root of 4,294,967,297, Euler could search only numbers of the form 128k + 1. That is a far shorter list, and it is how Euler found 641: 641 = 5 x 128 + 1, so it fits the required shape exactly.
Dividing 4,294,967,297 by 641 gives 6,700,417. The factorization is exact: F(5) = 4,294,967,297 = 641 x 6,700,417. Euler accomplished this about a century after Fermat claimed all such numbers were prime. The restricted factor form did not guarantee a factor would be found quickly, but it made the search practical enough to settle the question for F(5).
The result is more than a single counterexample. F(0) to F(4) remain the only known Fermat primes. Every Fermat number beyond that point that has been fully factored turns out to be composite, and F(5) is the first case where the pattern breaks. The restricted form of possible factors remains a useful starting point for anyone studying these numbers, because it narrows the candidates before any division is attempted.
- F(5) = 2^(2^5) + 1 = 4,294,967,297.
- Any prime factor of F(n) must have the form k x 2^(n+2) + 1.
- For F(5), candidates must be of the form 128k + 1; 641 = 5 x 128 + 1.
- F(5) = 641 x 6,700,417, factored by Euler about a century after Fermat's claim.
- F(0) to F(4) remain the only known Fermat primes.
Why Fermat primes still matter
Fermat numbers are more than a curiosity from number theory. They connect directly to one of the oldest questions in geometry: which regular polygons can be drawn with only a compass and a straightedge? The answer, proved by Carl Friedrich Gauss, is that a regular polygon with a prime number of sides p is constructible exactly when p is a Fermat prime. That single link is why these numbers still appear in classrooms and why a fermat number calculator is useful for checking them quickly.
The connection works because constructing a regular p-gon is equivalent to constructing a length related to the p-th roots of unity, and the algebra of that construction depends on whether p − 1 is a power of 2. Fermat primes have exactly this shape: each one is 1 more than a power of 2. Since Fermat numbers have the form F(n) = 2^(2^n) + 1, the exponent doubles at every step. The first few are small enough to check by hand: F(3) = 257 and F(4) = 65,537 are prime. Those two primes mean a regular 257-gon and a regular 65,537-gon are constructible in principle, even though drawing the latter by hand is not something anyone would attempt.
The story also shows why caution matters. Fermat believed every number of this form was prime, but he was wrong. F(5) = 4,294,967,297 = 641 x 6,700,417, and Euler found that factorization about a century after Fermat made his claim. Euler did not stumble on 641 by brute force. He used a rule: any prime factor of F(n) must have the form k x 2^(n+2) + 1. For n = 5, that means factors of the form 128k + 1, and 641 is one of them. This restriction is why factoring Fermat numbers, even enormous ones, is more tractable than factoring a random integer of the same size.
Today F(0) to F(4) remain the only known Fermat primes. Every larger Fermat number that has been fully checked turns out to be composite, and no one knows whether another Fermat prime exists. That open question is part of why the numbers still matter: they sit at the intersection of constructible geometry, factorization methods, and unsolved problems about primes.
For a general audience, the practical takeaway is simple. If you want to know whether a regular polygon with a prime number of sides can be constructed, check whether that prime is a Fermat prime. A fermat number calculator lets you generate F(n) and see how quickly the values grow, which makes the rarity of these primes easier to appreciate.
- A regular p-gon is constructible with compass and straightedge only if p is a Fermat prime.
- F(3) = 257 and F(4) = 65,537 are prime, so regular 257-gons and 65,537-gons are constructible in principle.
- F(5) = 4,294,967,297 = 641 x 6,700,417; Euler factored it about a century after Fermat claimed all such numbers were prime.
- Any prime factor of F(n) must have the form k x 2^(n+2) + 1, the rule Euler used to find 641.
- F(0) to F(4) remain the only known Fermat primes.
FAQs
What is a Fermat number?
A Fermat number is a number of the form 2^(2^n) + 1, where n is a nonnegative whole number. The exponent itself grows as a power of two, so the numbers get large quickly. For example, F(3) = 257. This calculator works with that definition to compute Fermat numbers and test their properties.
How many Fermat primes are known?
Five Fermat primes are known: F(0) through F(4), ending at 65,537. A Fermat prime is a Fermat number that is also a prime number. These five are the only known Fermat primes, and no others have been found. The calculator can help you check the smaller ones directly.
Who factored F(5)?
Euler factored F(5), showing that F(5) = 641 x 6,700,417. That product means F(5) is composite, not prime. This result mattered because Fermat had guessed that all Fermat numbers were prime, and F(5) was the first counterexample. You can verify the multiplication with the calculator.
How big is F(5)?
F(5) equals 4,294,967,297, which is 10 digits long. That is large enough to be awkward by hand but still small enough for a calculator to handle. Because it factors as 641 x 6,700,417, it is composite. The calculator can show this value and confirm the factorization.
Are any Fermat numbers beyond F(4) known to be prime?
No. Every Fermat number from F(5) onward that has been fully tested is composite. That covers all the Fermat numbers checked so far, and none has turned out to be prime. Testing larger ones is hard because the numbers grow extremely fast, so many remain untested rather than proven composite.
What are Fermat primes used for?
Fermat primes decide which regular polygons can be drawn with ruler and compass, by the Gauss-Wantzel theorem. The theorem ties constructible regular polygons to Fermat primes, so knowing which Fermat numbers are prime tells you which polygons are possible. This connects the calculator's results to a classic geometry question.