# Find all $n$ such that $2^n+1$ and $2^n-1$ are primes [duplicate]

Find all $$n\in \mathbb N$$ such that $$2^n+1$$ and $$2^n-1$$ are both primes .

My Attempt:

let $$p=2^n+1$$ and $$q=2^n-1$$

claim: $$n=2\implies p=5, q=3$$ is the only solution, because otherwise $$2^n+1$$ or $$2^n-1$$ would be divisible by $$5$$ or $$3$$.

if $$3\mid 2^n+1\iff 2^n+1\equiv 0 \pmod 3 \implies 2^{n-1}\equiv 1 \pmod 3$$.

But i don't know how to prove this claim.

• – Martin R Feb 28 at 13:47
• For the Mersenne primes, the exponent must be prime, for the Fermat primes, it must be a power of $2$. Which numbers have both properties ? – Peter Feb 28 at 13:52

You are kinda on the right track. Note that one of $$2^n-1, 2^n, 2^n+1$$ is divisible by $$3$$, and one of them is never divisible by $$3$$. Hence if $$2^n-1 > 3$$, one of $$2^n-1, 2^n+1$$ is composite.
• How did you know that one of them is divisible by $3$ – Yassir Feb 28 at 13:52
• $2\equiv (-1)\pmod 3 \implies 2^n\equiv (-1)^n\pmod 3$ Then either $$\cases{2^n-1\equiv 0\pmod 3 \\ 2^n+1\equiv 0 \pmod 3}$$ Am i right? – Yassir Feb 28 at 13:57
• That is correct, so which of $2^n\pm1$ is divisible by $3$ depends on whether $n$ is odd or even. – player3236 Feb 28 at 14:00