Find all possible solutions of $$2^x + 3^y = z^2.$$
My approach.
First I substituted $x = 0$, and got the solution, then for $y = 0$. And for $x > 0$ and $y > 0$ , I just know the Pythagorean triple and got the solution as $(4,2,5)$ and $(4,2,-5)$. Please help me to solve it properly.
Reducing modulo $3$ shows that $$2^x\equiv z^2\pmod{3}.$$ and so $x$ is even, say $x=2w$, because $2$ is not a square modulo $3$. Then we can rewrite the equation to get $$3^y=z^2-2^{2w}=(z-2^w)(z+2^w).$$ By unique factorization, both $z-2^w$ and $z+2^w$ are powers of $3$, say $$z-2^w=3^u\qquad\text{ and }\qquad z+2^w=3^v.$$ Of course then $u<v$. Putting these two together then shows that $$3^u(3^{v-u}-1)=3^v-3^u=(z+2^w)-(z-2^w)=2^{w+1}.$$ Again by unique factorization, we see that $u=0$ and hence $3^v-1=2^{w+1}$.
The only solutions${}^1$ are $(v,w)=(1,0)$ and $(v,w)=(2,2)$, corrresponding to $(x,y)=(0,1)$ and $(x,y)=(4,2)$ respectively, yielding the following solutions $(x,y,z)$: $$(0,1,2),\ (0,1,-2),\ (4,2,5),\ (4,2,-5).$$