<s>[INST] 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? 
 [/INST] 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.
</s>