ArticleslgStudy

mathematics

Fermat number

Fermat number is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Fermat number rather than just read about it. In short: In mathematics, a Fermat number, named after Pierre de Fermat (1601–1665), the first known to have studied them, is a positive integer of the form: Fn=22n+1, where n is a non-negative integer. The first few Fermat numbers are: 3, 5, 17, 257, 65537, 4294967297, 18446744073709551617, 340282366920938463463374607431768211457, ...

Fermat number — main illustration
Fermat number — illustration

Key takeaways

  • Fermat number belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Fermat number to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Fermat number from memory before moving on to harder problems.

Reference excerpt

In mathematics, a Fermat number, named after Pierre de Fermat (1601–1665), the first known to have studied them, is a positive integer of the form: Fn=22n+1, where n is a non-negative integer. The first few Fermat numbers are: 3, 5, 17, 257, 65537, 4294967297, 18446744073709551617, 340282366920938463463374607431768211457, ... (sequence A000215 in the OEIS). If 2k + 1 is prime and k > 0, then k itself must be a power of 2, so 2k + 1 is a Fermat number; such primes are called Fermat primes. As of 2026, the only known Fermat primes are F0 = 3, F1 = 5, F2 = 17, F3 = 257, and F4 = 65537 (sequence A019434 in the OEIS).

Basic properties The Fermat numbers satisfy the following recurrence relations:

Fn=(Fn−1−1)2+1 Fn=F0F1⋯Fn−1+2 for n ≥ 1,

Fn=Fn−1+22n−1F0F1⋯Fn−2 Fn=(Fn−1−2Fn−2+1)2+(2(Fn−2−2)(Fn−3−1))2+(2Fn−2−3)2 Fn=Fn−12−2(Fn−2−1)2 for n ≥ 2. Each of these relations can be proved by mathematical induction. From the second equation, we can deduce Goldbach's theorem (named after Christian Goldbach): no two Fermat numbers share a common integer factor greater than 1. To see this, suppose that 0 ≤ i < j and Fi and Fj have a common factor a > 1. Then a divides both

F0F1⋯Fj−1 and Fj; hence a divides their difference, 2. Since a > 1, this forces a = 2. This is a contradiction, because each Fermat number is clearly odd. As a corollary, we obtain another proof of the infinitude of the prime numbers: for each Fn, choose a prime factor pn; then the sequence {pn} is an infinite sequence of distinct primes.

Further properties No Fermat prime can be expressed as the difference of two pth powers, where p is an odd prime. With the exception of F0 and F1, the last decimal digit of a Fermat number is 7. The sum of the reciprocals of all the Fermat numbers (sequence A051158 in the OEIS) is irrational. (Solomon W. Golomb, 1963)

Primality Fermat numbers and Fermat primes were first studied by Pierre de Fermat, who conjectured that all Fermat numbers are prime. Indeed, the first five Fermat numbers F0, ..., F4 are easily shown to be prime. Fermat's conjecture was refuted by Leonhard Euler in 1732 when he showed, by dividing by 641 that

F5=225+1=232+1=4294967297=641×6700417 Euler proved that every factor of Fn must have the form k 2n+1 + 1 (later improved to k 2n+2 + 1 by Lucas) for n ≥ 2. That 641 is a factor of F5 can be deduced, in hindsight, as follows: From the equalities 641 = 27 × 5 + 1 and 641 = 24 + 54. It follows from the first equality that 27 × 5 ≡ −1 (mod 641) and therefore (raising to the fourth power) that 228 × 54 ≡ 1 (mod 641). On the other hand, the second equality implies that 54 ≡ −24 (mod 641). These congruences imply that 232 ≡ −1 (mod 641). Fermat was probably aware of the form of the factors later proved by Euler, so it seems curious that he failed to follow through on the straightforward calculation to find the factor. One common explanation is that Fermat made a computational mistake. There are no other known Fermat primes Fn with n > 4, but little is known about Fermat numbers for large n. In fact, each of the following is an open problem:

Is Fn composite for all n > 4? Are there infinitely many Fermat primes? (Eisenstein 1844) Are there infinitely many composite Fermat numbers? Does a Fermat number exist that is not square-free? As of December 2025, it is known that Fn is composite for 5 ≤ n ≤ 32, although of these, complete factorizations of Fn are known only for 0 ≤ n ≤ 11, and there are no known prime factors for n = 20 and n = 24. The largest Fermat number known to be composite is F18233954, and its prime factor 7 × 218233956 + 1 was discovered in October 2020.

Heuristic arguments Heuristics suggest that F4 is the last Fermat prime. The prime number theorem implies that a random integer in a suitable interval around N is prime with probability 1 / ln N. If one uses the heuristic that a Fermat number is prime with the same probability as a random integer of its size, and that F5, ..., F32 are composite, then the expected number of Fermat primes beyond F4 (or equivalently, beyond F32) should be

∑n≥331ln⁡Fn<1ln⁡2∑n≥331log2(22n)=1ln⁡22−32<3.36×10−10. One may interpret this number as an upper bound for the probability that a Fermat prime beyond F4 exists. This argument is not a rigorous proof. For one thing, it assumes that Fermat numbers behave "randomly", but the factors of Fermat numbers have special properties. Boklan and Conway published a more precise analysis suggesting that the probability that there is another Fermat prime is less than one in a billion. Anders Bjorn and Hans Riesel estimated the number of square factors of Fermat numbers from F5 onward as

∑n≥5∑k≥11k(k2n+1)ln⁡(k2n)<π26ln⁡2∑n≥51n2n≈0.02576; in other words, there are unlikely to be any non-squarefree Fermat numbers, and in general square factors of a2n+b2n are very rare for large n.

Equivalent conditions

Let Fn=22n+1 be the nth Fermat number. Pépin's test states that for n > 0,

Fn is prime if and only if 3(Fn−1)/2≡−1(modFn). The expression 3(Fn−1)/2 can be evaluated modulo Fn by repeated squaring. This makes the test a fast polynomial-time algorithm. But Fermat numbers grow so rapidly that only a handful of them can be tested in a reasonable amount of time and space. There are some tests for numbers of the form k 2m + 1, such as factors of Fermat numbers, for primality.

Proth's theorem (1878). Let N = k 2m + 1 with odd k < 2m. If there is an integer a such that a(N−1)/2≡−1(modN) then N is prime. Conversely, if the above congruence does not hold, and in addition (aN)=−1 (See Jacobi symbol) then N is composite. If N = Fn > 3, then the above Jacobi symbol is always equal to −1 for a = 3, and this special case of Proth's theorem is known as Pépin's test. Although Pépin's test and Proth's theorem have been implemented on computers to prove the compositeness of some Fermat numbers, neither test gives a specific nontrivial factor. In fact, no specific prime factors are known for n = 20 and 24.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Fermat number

Start with the simplest possible case. Write down what Fermat number claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Fermat number before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Fermat number ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Fermat number

In research
Fermat number appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Fermat number in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Fermat number is common in secondary-school and first-year university syllabi. It links to neighbouring topics Classes of prime numbers, Constructible polygons, Integer sequences, so understanding it makes those chapters shorter.
In everyday life
Look for Fermat number outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Fermat number” →

How to study Fermat number in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Fermat number means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Fermat number out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Fermat number in simple terms?

In mathematics, a Fermat number, named after Pierre de Fermat (1601–1665), the first known to have studied them, is a positive integer of the form: Fn=22n+1, where n is a non-negative integer. The first few Fermat numbers are: 3, 5, 17, 257, 65537, 4294967297, 18446744073709551617, 3402823669209384…

Why does Fermat number matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Fermat number?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Fermat number.

Tags

  • Classes of prime numbers
  • Constructible polygons
  • Integer sequences
  • Large integers
  • Pierre de Fermat
  • Unsolved problems in number theory

Keep exploring