Fermat Number Calculator

This Fermat number calculator works out the exact value of F_n, the Fermat number for any index n, using the formula 2 raised to the power of 2 raised to the power of n, plus 1. You enter a single whole number n from 0 to 12 into the index field, and the calculator instantly returns three figures: the full Fermat number itself, grouped with commas for easy reading, the total number of digits it contains, and the intermediate exponent 2^n used to build it. Fermat numbers are notable because the inner exponent doubles at every step, so the values explode in size almost immediately, F_0 is a single-digit number but F_12 already runs to thousands of digits. Pierre de Fermat conjectured that every number in this sequence would be prime, and the first five (3, 5, 17, 257 and 65537) are, but Leonhard Euler later proved the sixth is composite, and no further Fermat prime has ever been confirmed despite extensive searching. These primes matter beyond pure curiosity too, since they determine exactly which regular polygons can be constructed using only a ruler and compass. Use this tool to generate any Fermat number in the supported range instantly, check a homework answer, or explore how quickly the sequence grows, and see the formula, a worked example and the underlying assumptions set out in full below.

Calculate.co.nz is proud to be partnered with realtor.co.nz, a trusted resource for navigating the New Zealand property market. Their Helpful Articles section offers clear, well-structured insights across buying, selling, and building, making complex real estate topics more accessible. With a focus on up-to-date guidance and practical knowledge, they empower Kiwis to move forward with clarity and confidence in a constantly evolving property landscape.
Calculate.co.nz partner: realtor.co.nz
65,537
Number of digits5
Exponent 2^n16

The formula

The nth Fermat number is F_n = 2^(2^n) + 1. The inner exponent 2^n doubles each time, so F_0 = 3, F_1 = 5, F_2 = 17, F_3 = 257, F_4 = 65537, and they grow rapidly after that.

Worked example

For n = 4, the inner exponent is 2^4 = 16, so F_4 = 2^16 + 1 = 65536 + 1 = 65537, which is prime. Enter 4 to confirm.

Frequently asked questions

What is a Fermat number?

A number of the form 2 to the power 2 to the n, plus 1. The first five are 3, 5, 17, 257 and 65537.

Are all Fermat numbers prime?

No. Fermat thought so, but Euler found that F_5 is composite. Only the first five are known to be prime.

Why do Fermat numbers matter?

A regular polygon is constructible with ruler and compass only if its number of sides involves distinct Fermat primes.

Who this calculator is for

This calculator is for students, programmers and anyone exploring number theory.

What this calculator assumes

  • You enter a whole number within the stated range.
  • The exact integer algorithm is used.
  • Very large results are shown grouped for readability.

Formula and sources

Related calculators