Fermat Number Calculator
Compute a Fermat number 2 to the 2 to the n plus one, printed as a full exact integer.
What it does
Fermat numbers have the form two raised to the power two to the n, plus one. The first few are 3, 5, 17, 257 and 65537. Pierre de Fermat observed that these five are prime and conjectured that every such number is prime, a guess that turned out to be wrong.
The sixth value, 4294967297, was later shown to factor as 641 times 6700417. Many larger Fermat numbers have also been proved composite, and no further Fermat prime is known. The question remains a good example of how a short pattern of small cases can mislead.
Fermat numbers grow astonishingly fast. Each step squares the previous value minus one, so the number of digits roughly doubles as the index rises. By index 10 the value has more than three hundred digits.
This page computes the chosen value with arbitrary precision integer arithmetic and prints every digit. It also reports the inner exponent and the digit count so the size is clear before you read the full number.
The index limit is 10. That keeps the displayed value manageable while still showing how quickly the sequence explodes.
How to use
- Enter an index n from 0 to 10.
- Read F(n) in the main result box.
- Check the inner exponent two to the n beside it.
- Use the digit count to judge the size of the value.
- The default index 5 reproduces the worked example.
- Try index 4 to see the largest Fermat number known to be prime.
Formula
- n
- The index of the Fermat number.
- 2^n
- The inner exponent.
- F(n)
- The Fermat number at index n.
The values satisfy the identity F(n) = F(0) x F(1) x ... x F(n - 1) + 2, which gives a quick way to confirm small terms. A Fermat number is prime only if its index is a power of two in a broader generalized sense, but this page uses the standard indexing and makes no primality claim.
Worked example
Example: F(5)
The page opens with index 5.
- Compute the inner exponent: 2^5 = 32.
- Write the definition: F(5) = 2^32 + 1.
- Compute 2^32 = 4,294,967,296.
- Add one to get 4,294,967,297.
- The tool reports 4294967297, exponent 32 and 10 digits.
- Check the product identity: F(0) through F(4) multiply to 4,294,967,296, one less than this value.
- This number factors as 641 x 6,700,417, so it is not prime.
Reference table
| n | 2^n | F(n) | Digits |
|---|---|---|---|
| 0 | 1 | 3 | 1 |
| 1 | 2 | 5 | 1 |
| 2 | 4 | 17 | 2 |
| 3 | 8 | 257 | 3 |
| 4 | 16 | 65537 | 5 |
| 5 | 32 | 4294967297 | 10 |
Limits
- Indices above 10 are rejected so the printed value stays manageable.
- The tool does not test primality or give factors.
- The full integer is shown, which is long at the upper end of the range.
- Generalized Fermat numbers with other bases are not covered.
Common mistakes
- Confusing 2^(2^n) with (2^2)^n, which equals 4^n.
- Forgetting the final plus one.
- Assuming every Fermat number is prime because the first five are.
- Using a floating point power and losing digits.
- Starting the index at 1 instead of 0.
Try it yourself
Quick checks. Answers sit tucked under each question.
What is F(5)?
F(5) = 2^32 + 1 = 4,294,967,297, a ten digit composite number.
What is F(4)?
F(4) = 2^16 + 1 = 65,537.
What is F(0)?
F(0) = 2^1 + 1 = 3.
Questions
Are all Fermat numbers prime?
No. The first five are, but F(5) and many later ones are composite.
Why do they grow so fast?
The exponent itself doubles each step, so each term is roughly the square of the previous one.
Is there a link to constructible polygons?
Yes. Fermat primes correspond to regular polygons constructible with straightedge and compass.
What is the largest index here?
Ten, which gives a number with more than three hundred digits.
Does the tool print scientific notation?
No. Every digit of the integer is shown.
Does this test primality?
No. It only computes the value.