Solution 1:

The equation $$2^n-7=x^2$$ is called the Ramanujan–Nagell equation. It has been conjectured by Ramanujan and proven by Nagell, and later others, that the only solutions are $n=3,4,5,7$ and $15$. Here are two proofs:

  • one originally due to Hasse
  • another by Wells Johnson

I believe all proofs make use of unique factorization in the ring of integers of $\mathbb{Q}(\sqrt{-7})$.

Solution 2:

So, there were just a few solutions to $2^n = x^2 + 7.$

The other side is, for $n \geq 3,$ there is always a solution to $$ 2^n = x^2 + 7 y^2 $$ with $\gcd(x,y)=1.$ Proof by induction; as I recall, to keep the gcd thing, we demand that $x \equiv y \equiv 1 \pmod 4$ for all $n,$ which sometimes requires $x$ or $y$ or both to be negative. Note that it would not be impressive if we allowed $x,y$ even, because doubling both $x,y$ just adds $2$ to $n.$

I'm just saying.