TITLE: Solve $2^m=7n^2+1$
QUESTION [7 upvotes]: Solve $2^m=7n^2+1$ with $(m,n)\in \mathbb{N}^2$
Here is what I did:
First try, I have seen first that the obvious solutions are $n=1$ and $m=3$ , and $n=3$ and $m=6$, then I proved by simple congruences that $m$ must be divisible by $3$ so $m=3k$, If we add $27$ to the equation we will have $2^{3k}+3^3=7(n^2+2^2)$, but unfortunately I tried to do something with Legendre symbol or the multiplicative order but I found nothing interesting.
Second try,I let $n=2k+1$ then I worked in $\mathbb{Z}\left[ \frac{-1+\sqrt{-7}}{2} \right] $ and the equation becomes $7\times 2^{m-2}=\left( 7k+4+\frac{-1+\sqrt{-7}}{2} \right) \left( 7k+3-\frac{-1+\sqrt{-7}}{2} \right) $ but I didn't find something interesting because the two factors are not coprime.

REPLY [2 votes]: If $2^m=7n^2+1$ with $m=3k$, as the OP found must be the case (since $2^m\equiv1$ mod $7$), we have
$$7n^2=2^{3k}-1=(2^k-1)(2^{2k}+2^k+1)$$
Now for $k\ge1$ we have
$$\begin{align}
\gcd(2^k-1,2^{2k}+2^k+1)
&=\gcd(2^k-1,2^{2k}+2^{k+1})\\
&=\gcd(2^k-1,2^{k+1}(2^{k-1}+1))\\
&=\gcd(2^k-1,2^{k-1}+1)\\
&=\gcd(2^k+2^{k-1},2^{k-1}+1)\\
&=\gcd(3\cdot2^{k-1},2^{k-1}+1)\\
&=\gcd(3,2^{k-1}+1)\\
&=\begin{cases}
3\quad\text{if $k$ is even}\\
1\quad\text{if $k$ is odd}
\end{cases}
\end{align}$$
If $k$ is even, we proceed as in Mastrem's answer: $k=2h$ implies $7n^2=2^{6h}-1=(2^{3h}-1)(2^{3h}+1)$ with $\gcd(2^{3h}-1,2^{3h}+1)=1$ and $7\mid(2^{3h}-1)$, so $2^{3h}+1$ must be a square, but $2^{3h}+1=N^2$ implies $2^{3h}=(N-1)(N+1)$, which holds only for $N=3$, corresponding to the known solution with $m=6$.
If $k$ is odd, then we must have $7$ divide one of the factors in $(2^k-1)(2^{2k}+2^k+1)$ and the other factor be a square. If $k\ge3$, $2^k-1\equiv-1$ mod $8$, which is not a square, so we must have $7\mid2^k-1$, which implies $k=3h$ (with $h$ odd, but that's no longer important), from which it follows that $2^{6h}+2^{3h}+1$ is a square. But $2^{6h}+2^{3h}+1\equiv1+1+1\equiv3$ mod $7$, which is not a square. So the case of odd $k$ leaves only $k=1$, corresponding to the other known solution, $m=3$.