Primality criterion for Mersenne numbers involving Euler’s totient function

elementary-number-theoryexamples-counterexamplesmersenne-numbersprimality-test

I am looking for a proof of the following claim:

Let $M_p=2^p-1$ where $p$ is a prime . Denote Euler's totient function by $\varphi(n)$ . Then,
$$M_p \text{ is prime iff } \varphi(M_p) \equiv 2 \pmod{4}$$

The SageMath cell that demonstrates this claim can be found here. I have checked claim for all $p$ below $260$. Clearly, if $M_p$ is prime we have $M_p \equiv 3 \pmod{4}$ and since $\varphi(q)=q-1$ for any prime $q$ it follows that $\varphi(M_p) \equiv 2 \pmod{4}$ . But how to prove this claim in the opposite direction?

Best Answer

Suppose $2^p-1$ is composite, then it is not a prime power by Mihăilescu's theorem. Let $q,r\mid 2^p-1$ be two distinct prime factors, then both $q$ and $r$ are odd, whence $\varphi(q)$ and $\varphi(r)$ are both even. It follows that $$4\mid\varphi(q)\varphi(r)=\varphi(qr)\mid \varphi(2^p-1).$$

Related Question