**A number of the form 2 ^{x} + 1 (where x > 0) is prime if and only if x is a power of 2, i.e., x = 2^{n}**. So overall number becomes 2

^{2n}+ 1. Such numbers are called Fermat Number (Numbers of form 2

^{2n}+ 1). The first few Fermet numbers are 3, 5, 17, 257, 65537, 4294967297, ….

An important thing to note is a number of the form 2^{2n} + 1) is not always prime. For example 2^{25} + 1 = 2^{5} + 1 = 2^{32} + 1 = 4294967297 = 641 * 6700417.

This fact is contributed by **Shivam Pradhan (anuj_charm)**. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

## Recommended Posts:

- GFact 23 | (Brocard’s problem)
- Sum of each element raised to (prime-1) % prime
- Print all numbers whose set of prime factors is a subset of the set of the prime factors of X
- Check if a number is Prime, Semi-Prime or Composite for very large numbers
- Count all prime numbers in a given range whose sum of digits is also prime
- Count prime numbers that can be expressed as sum of consecutive prime numbers
- Prime numbers and Fibonacci
- First N natural can be divided into two sets with given difference and co-prime sums
- Pollard's Rho Algorithm for Prime Factorization
- Find power of power under mod of a prime
- Check if a number can be written as a sum of 'k' prime numbers
- An interesting solution to get all prime numbers smaller than n
- Express an odd number as sum of prime numbers
- N expressed as sum of 4 prime numbers
- Largest power of k in n! (factorial) where k may not be prime
- K-Primes (Numbers with k prime factors) in a range
- Sexy Prime
- Find largest prime factor of a number
- Sum of largest divisible powers of p (a prime number) in a range
- Find First element in AP which is multiple of given prime