Discrete math. Finding a perfect square.

The problem is: Find all natural numbers $n$ for which $2^n + 1$ is a perfect square?

I am having a bit of trouble finding a generic way of finding these numbers. Of course the first obvious solution is $n = 3.$ For which we have $8 + 1 = 3^2.$ Anyone has any smart ideas?


Solution 1:

$$ 2^n+1=m^2\implies 2^n=(m-1)(m+1). $$ This implies that $(m-1)$ and $(m+1)$ are both powers of $2$. In particular, $m-1$ divides $m+1$ so that $m-1$ divides $(m+1)-(m-1)=2$. This means that $m-1$ is either $2$ or $1$. Only $m-1=2$ works, so $m=3$ and $n=3$ constitute the only solution.

Solution 2:

Method $\#1:$

If $2^n+1=m^2\iff2^n=(m+1)(m-1)$

We can easily test for $n\le2$

For $n>2,$ clearly $m$ is odd

and we have $$2^{n-2}=\frac{m-1}2\cdot\frac{m+1}2$$

But as $\displaystyle\frac{m+1}2-\frac{m-1}2=1,\left(\frac{m-1}2,\frac{m+1}2\right)=1,$ at least one of them is odd

But each divides $2^{n-2},$ the odd must be $\pm1$

If $\displaystyle\frac{m-1}2=1, m=3$ which is a legitimate solution

If $\displaystyle\frac{m+1}2=-1, m=-3$ which is also a valid solution

But, $\displaystyle\frac{m-1}2=-1$ and $\displaystyle\frac{m+1}2=1$ makes $2^n=0$

Method $\#2:$

If $n\ge1,2^n+1$ is odd, for the existence of a square we need $2^n+1=(2a+1)^2\iff2^n=4a(a+1),4$ must divide $2^n\implies n\ge2$

So, we have $2^{n-2}=a(a+1)$ and again, $(a+1,a)=(a+1-a,a)=1$

As exactly, one of $a,a+1$ is odd

Now any odd divisor of $2^{n-2}$ must be $\pm1$

Case $\#1:$ If $a$ is odd

Case $\#2:$ If $a+1$ is odd