Algebra - Solving for three unknowns. 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. 
 A: 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).$$


*

*This is a special case of Mihăilescu's theorem, previously known as Catalan's conjecture. This special case is classical, and is easily seen by reducing mod $8$; this shows that if $w\geq2$ then $v$ must be even, say $v=2t$, and so
$$2^{w+1}=3^v-1=3^{2t}-1=(3^t-1)(3^t+1).$$
Then both factors on the right hand side are powers of $2$, and they differ by $2$, so $t=1$.

A: If $x,y>0$ then working mod $3$ we have $2^x\equiv 1$ so $x$ is even. Working mod $4$ gives $y$ even. So $(2^{x/2})^2+(3^{y/2})^2=z^2$, meaning $(2^{x/2},3^{y/2},|z|)$ form a pythagorean triple.
Any pythagorean triple can be written as $(a(b^2-c^2), 2abc, a(b^2+c^2))$ for some positive integers $a,b,c$ (where the first two terms can be in either order). So we must have $2abc$ is a power of $2$, and so $a(b^2-c^2)$ is a power of $3$. This means $a=c=1$, $b$ is a power of $2$, and $(b-1)(b+1)$ is a power of $3$, hence $b$ must be $2$. This means the only option for $x,y>0$ is $2^{x/2}=8, 3^{y/2}=3, |z|=5$.
