If $2^n - 1$ is prime from some integer $n$, prove that n must also be prime.

I understand the idea of the proof. I just want to make sure I wrote my proof well.

Suppose $n$ is not prime. Then $\exists x,y \in \mathbb{Z}$ such that $n = xy$.

$2^{xy} - 1 = (2^x)^y - 1$

$ = (2^y - 1)(2^{y(x-1)} + 2^{y(x-2)} + ... + 2^{y} + 1)$

Since $2^{n} - 1$ is divisible by $2^y - 1$ it must be that $2^n - 1$ is not prime. Contradiction. Thus $n$ must be prime.

How does this look?


I'll try to recapituate all the comments made in an adapted version of the proof.

If $2^n−1$ is prime from some integer$~n$, then $n$ must also be prime.

Since the hypothesis requires $n\geq2$ to be true, one may assume that. We prove the contrapositive: if $n\geq2$ is not prime then $2^n-1$ is not prime either.

Suppose $n\geq2$ is not prime. Then there exist integers $x,y>1$ such that $n = xy$.

One has $2^n-1 = 2^{yx} - 1 = (2^y)^x - 1 = (2^y - 1)(2^{y(x-1)} + 2^{y(x-2)} + \cdots + 2^{y.1} + 2^{y.0})$. Since $y>1$ the first factor $2^y - 1$ is${}>1$, and since $x>1$ that factor is less than $2^n-1$.

Since $2^n - 1$ has a proper divisor $2^y - 1$ greater than$~1$, we have shown that $2^n - 1$ is composite, establishing the contrapositive.

Remark. The contrapositive statement proved remains true if powers of $2$ are replaced throughout by powers of some integer $a\geq2$. However with that change it is no longer true that the original hypothesis requires $n\geq2$, as $n=1$ might work. Therefore such a generalisation of the original statement requires an explicit additional hypothesis $n\geq2$.


Perhaps a minor nit-pick, but it seems the middle step should be $((2^y)^x-1)$, since you're utilizing the identity $$a^x-1=(a-1)(a^{x-1}+a^{x-2}+\cdots+a+1)$$ with $a=2^y$.