Mersenne primes are prime numbers of the form 2p−1, where p is prime. They are named after the French mathematician Marin Mersenne (1588-1648).
Some examples are 3 = 22−1, 7 = 23−1, and 31 = 25−1. Not all numbers of the form 2p−1 are prime. For example, 2047 = 211−1 = 23 * 89, is not prime.
For fun, we'll show that any number of the form 2m−1, where m is a composite number, cannot be prime. That is, if a number of the form 2m−1 is prime, then m is prime.
Proof: Let m = ab, where a and b are integers greater than 1. We use the identity xn−1 = (x−1)(xn−1 + xn−2 + ··· + 1).
So we have 2m−1 = 2ab−1 = (2a)b−1, which is divisible by 2a−1, and we are done.
Note: One consequence of the above result is that we could have defined a Mersenne prime equally well as any prime of the form 2n−1, where n is any integer.
Source: wikipedia.org
Note: To prove the identity, we have
(x−1)(xn−1 + xn−2 + ··· + 1) = (x−1)Σn−10 xk = xΣn−10 xk − Σn−10 xk
Let's examine more closely the first term of the final expression above:
xΣn−10 xk = Σn−10 xk+1
= Σn1 xk
= xn + Σn−11 xk
= xn + Σn−10 xk − 1
Finally, we have (x−1)(xn−1 + xn−2 + ··· + 1) = xΣn−10 xk − Σn−10 xk
= xn + Σn−10 xk − 1 − Σn−10 xk = xn−1