I have been researching Mersenne primes so I can write a program that finds them. A Mersenne prime looks like $2^n-1$. When calculating them, I have noticed that the $n$ value always appears to be odd. Is there confirmation or proof of this being true?


Theorem. If $2^n-1$ is prime then $n$ is prime.

Proof. Suppose that $2^n-1$ is prime, and write $n=st$ where $s,t$ are positive integers. Since $$x^s-1=(x-1)(x^{s-1}+x^{s-2}+\cdots+1)\ ,$$ we can substitute $x=2^t$ to see that $2^t-1$ is a factor of $2^n-1$. Since $2^n-1$ is prime there are only two possibilities, $$2^t-1=1\quad\hbox{or}\quad 2^t-1=2^n-1\ .$$ Therefore $t=1$ or $t=n$. We have shown that the only possible factorisations of $n$ are $n\times1$ and $1\times n$. Hence, $n$ is prime.

Comment. If $n$ is prime it is not always true that $2^n-1$ is prime. For example, $2^{11}-1=23\times89$.


Note that for $m\ge 2$ $$2^{2m}-1=(2^m)^2-1=(2^m-1)(2^m+1)$$ is not a prime number.