Finding positive integral solutions of $3^a=b^2+2$ I am trying to find integral solutions of the equation $3^a=b^2+2$. I could get that $a$ and $b$ have to be odd. But I am unable to get any further. I believe that $(a,b)=(1,1);(3,5)$ are the only solutions but I am unable to show that. If any one has any hints, it would be great. Thanks
 A: The quadratic field $\mathbb Q(\sqrt {-2})$ we will use below in solving this question, is a very good field: its ring of integers is $\mathbb Z[\sqrt {-2}]$ (because $-2\equiv 2 (mod\space 4)) $; its only units are $\pm1$ (because $-2<0$ and distinct of $-1$ and$-3$); it is a registered unique factorization domain and, more, an Euclidean domain with Euclidean function defined by $|N(x)|$ where N is the norm . On the other hand $-2$ is clearly a quadratic residue modulo 3 (because $-2=1$ in $\mathbb F_3$) so, according to the theory, 3 is decomposed into two primes $p_1p_2$ in the ring $\mathbb Z[\sqrt {-2}]$. We have in fact $3=(1+\sqrt{-2})(1-\sqrt {-2})$ so we have
 $$3^a=b^2+2\iff 3^a=(1+\sqrt{-2})^a(1-\sqrt {-2})^a=(b+\sqrt{-2})(b-\sqrt{-2})$$
Suppose $x+y\sqrt{-2}$ is a common factor of  $(b+\sqrt{-2})$ and $(b-\sqrt{-2})$ then it divides their difference $2\sqrt{-2}$ then, taking norms in the Euclidean domain $\mathbb Z[\sqrt {-2}]$, one has $x^2+2y^2$ divides $8$; hence $x^2+2y^2=1,2,4,8$ which respectively gives $(x,y)=(1,0),(0,1),(2,0),(0,2)$. 
None of these give proper factors neither of $(b+\sqrt{-2})$ nor $(b-\sqrt{-2})$ hence  $(b+\sqrt{-2})$ and $(b-\sqrt{-2})$  are coprime.
Thus, by unique factorization one has $(1+\sqrt{-2})^a = b\pm\sqrt{-2}$ from which
$A_a+B_a\sqrt{-2}= b\pm\sqrt{-2} \Rightarrow B_a=\pm1$
Now calculating $B_a$ for $a\ge1$ we get the only values of the exponent $a$ for which we have $B_a=\pm1$ are $1$ and $3$; in fact, 
$a=1$ gives $(1+\sqrt{-2})=b+\sqrt{-2}$ hence the obvious solution $\boxed{(a,b)=(1,1)}$
$a=3$ gives $(1+\sqrt{-2})^3=1+3\sqrt{-2}+3(\sqrt{-2})^2+(\sqrt{-2})^3=-5+\sqrt{-2}$ hence the solution $\boxed{(a,b)=(3,5)}$ deduced from $3^3=27=b^2+2$.
The other values of $a$ are such that $|B_a|\gt1$ as one can see taking the odd powers in
$(1+\alpha)^a= 1+a\alpha+\binom a2\alpha^2+\cdot\cdot \cdot +\binom ak\alpha^k + \cdot \cdot\cdot +a{\alpha}^{a-1}+  {\alpha}^{a}+  $ with $\alpha=\sqrt{-2}$ so one has 
$$B_a= a+\binom a3(-2)+\binom a5(-2)^2+\cdot\cdot $$ in which it is verified $|B_a|\gt1$ when $a\neq 1,3$.
Finally the only solutions are the two above boxed ones.
A: Three cases:


*

*$a=3k$. Then $\left(3^k\right)^3=b^2+2$. But $x^3=y^2+2$ has $2$ integral solutions $(x,y)=(3,\pm 5)$ (see here, page $7$).

*$a=3k+1$. Then $\left(3^{k+1}\right)^3=(3b)^2+18$. But $x^3=y^2+18$ has $2$ integral solutions (http://oeis.org/A081120, in particular http://oeis.org/A081120/b081120.txt) $(x,y)=(3,\pm 3)$, so $(k,b)=(0,\pm 1)$, so $(a,b)=(1,\pm 1)$.

*$a=3k+2$. Then $\left(3^{k+2}\right)^3=(9b)^2+162$, no solutions (http://oeis.org/A081120/b081120.txt).
