When is $2^x+3^y$ a perfect square? 
If $x$ and $y$ are positive integers, then when is $2^x+3^y$ a perfect square?

I tried this question a lot but failed. I tried dividing cases into when $x,y$ are even/odd, but still have no idea what to do when they are both odd. I tried looking into when is  $2^x+3^y$ is of the form $6k+1$ and so on .. but couldn't succeed. Can anyone help? 
 A: If $x=1$, $2+3^y$ cannot be a square since it is $\equiv 2\pmod{3}$.
This gives $x\geq 2$, so $2^x+3^y\equiv (-1)^y\pmod{4}$ and $y$ must be even. Since in this case $3^y\equiv 1\pmod{8}$, we must have $x\geq 3$ and
$$ 2^x + 3^{2z} = A^2 $$
with $A$ odd, or:
$$ 2^x = (A-3^z)(A+3^z) \tag{1} $$
so both $A-3^x$ and $A+3^x$ must be powers of two, then:
$$ 2\cdot 3^z = 2^D-2^C\tag{2} $$
with $D>C$ and $C\geq 1$, since otherwise the RHS of $(2)$ is odd. But if $C>1$ then the RHS of $(2)$ is a multiple of four while the LHS is not, so $C=1$ and we are left with:
$$ 3^z = 2^E -1 \tag{3} $$
where $E$ must be even in order that the RHS is a multiple of three. But in such a case the only solution of:
$$ 3^z = (2^F-1)(2^F+1) \tag{4} $$
is given by $z=F=1$, since otherwise $2^F-1$ and $2^F+1$ cannot be both powers of three. 
This gives that
$$ 2^4+3^2 = 5^2 $$
is the only solution.
A: Hint: Note that $x$ is even (work modulo $3$).  Let $x=2s$. We are solving 
$$3^y=(z-2^s)(z+2^s).$$  Each term on the right is a power of $3$. But their difference is a power of $2$, and we are down to the familiar equation $3^y=2^{s+1}+1$.
A: Let $2^x+3^y=k^2$.
mod $3$ gives $x=2m$ for some $m\in\mathbb Z^+$, since $(-1)^x\equiv k^2\pmod {3}$ and since $2$ (i.e. $-1$) is not a quadratic residue mod $3$.
More generally, $\left(\frac{-1}{p}\right)=1\iff p\equiv 1\pmod {4}$, where $p$ is an odd prime and $\left(\frac{a}{b}\right)$ is the Legendre symbol.
Thus $4^m+3^y=k^2$.
So $(-1)^y\equiv k^2\pmod {4}$, but $\left(\frac{-1}{4}\right)=-1$. So $y=2n$ for some $n\in\mathbb Z^+$.
Thus $(2^{m})^2+(3^n)^2=k^2$.
Hence $(2^m,3^n,k)$ is a Pythagorean triple. Moreover, it is primitive, because $(2^m,3^n)=1$, which means:
$$\begin{cases}2^m=2ab\\3^n=a^2-b^2\\k=a^2+b^2\end{cases},$$
where exactly one of $a,b$ is odd.
This implies $(a,b)=(2^i,2^j)$ for some $i,j\in\mathbb Z^+$.
But exactly one of $a,b$ is odd (as I said before), and also $a>b\iff 2^i>2^j$.
Thus $j=0$ so that $(a,b)=(2^i,1)=(2^{m-1},1)$.
Then $4^{m-1}=3^n+1\iff (2^{m-1}-1)(2^{m-1}+1)=3^n$ so that $2^{m-1}-1$ and $2^{m-1}+1$ are powers of $3$, and because their difference is $2$, it follows that $2^{m-1}-1=1\iff m=2\iff x=4$, and $n=1\iff y=2$, which leads us to the only solution $(x,y)=(4,2)$, which after checking works.

The following is an alternative continuation of my solution using Zsigmondy's theorem.  
We have $4^{m-1}=3^n+1$ ($n$ is odd (check $\pmod 4$ and note that $m-1\ge 1$)), but Zsigmondy's theorem implies: 
$$\exists p\in\mathbb P (p\mid a^n+b^n\wedge p\not\mid a+b), \forall n\ge 2, a>b$$ (with the exception of $(a,b,n)=(2,1,3)$, which won't work here, since in our case $(a,b,n)=(3,1,n)$) so that $a^n+b^n$ has more than one prime divisor for any $n\ge 2, a>b$.  
Thus $n\ge 2$ and $3>1$ lead to a contradiction, which means $n=1\iff y=2$ and $m=2\iff x=4$.
This leads to $(x,y)=(4,2)$ as the only solution, which after checking works.

Yet another way I could've proceeded after seeing that $4^{m-1}=3^n+1$ is Catalan's conjecture (now proved), which tells us that $$\begin{cases}x^a-y^b=1\\x,a,y,b\in\mathbb Z_{>1}\end{cases}\iff (x,a,y,b)=(3,2,2,3)$$

Continuation of André Nicolas solution using Zsigmondy's theorem.
$3^y=2^{s+1}+1$.
Notice that $y\ge 1$ so that $s+1\ge 1$. Applying Zsigmondy's theorem leads to a contradiction whenever $s+1\ge 2$ and $2>1$ except for the exception $s+1=3$, which means either $s+1=1\iff (x,y)=(0,1)$, which doesn't work, or $s+1=3\iff s=2$, giving us the only solution $(x,y)=(4,2)$, which after checking works.
This could've also been solved using Catalan's conjecture (now proved), which I introduced above.
But, of course, the easiest route here is to note that (we have $y\ge 1$ and thus $s+1\ge 1$, but $s+1\neq 1$, so $s+1\ge 2$. Now assume $s+1\ge 2$) $\pmod{4}$ leads to $y=2c$ for some $c\in\mathbb Z^+$ so that $(3^c-1)(3^c+1)=2^{s+1}$ and thus $3^c-1=2\iff c=1\iff y=2$ and thus $s+1=3\iff s=2\iff x=4$.
It follows that $(x,y)=(4,2)$ is the only possible solution and after checking it it works.
