How to solve a Diophantine equation like $$3^n-1=2x^2$$. One can easily see that the parity of $n$ and $x$ will be same and equation further can be seen taking if $$n\equiv0\pmod3\quad \text{then }x \equiv0\pmod{13} $$ but I don't know what to do further.



Diophantine equation $3^n-1=2x^2$
This problem happens to have appeared on the Polish Mathematical Olympiad camp in 2015. Here is the official solution of the problem: (I use $m$ in place of $x$ because this is how the problem was stated there)


Suppose first $n$ is even, say $n=2k$. Then the equation is equivalent to $(3^k+1)(3^k-1)=2m^2$. Clearly $\gcd(3^k+1,3^k-1)=2$, so one of these numbers must be a perfect square (and the other one twice a perfect square). $3^k-1\equiv 2\pmod 3$, so it can't be a square, hence $3^k+1=t^2,3^k=(t-1)(t+1)$. Therefore, $t-1,t+1$ are powers of $3$. But they can't both be divisible by $3$, so $t-1=1,t=2$. This leads to solution $(m,n)=(2,2)$.


Now suppose $n$ is odd, say $n=2k+1$. Letting $t=3^k$ we get $3t^2-2m^2=1$. Setting $t=2v+u,m=3v+u$ (check $u,v$ are integers) we get the Pell's equation $u^2-6v^2=1$. Standard theory gives us that all its solutions are generated as follows:
$$(u\_0,v\_0)=(5,2),(u\_{i+1},v\_{i+1})=(5u\_i+12v\_i,2u\_i+5v\_i).$$
From this we can get a recurrence for $t=t\_i=2v\_i+u\_i$:
$$t\_{-1}=1,t\_0=9,t\_{i+2}=10t\_{i+1}-t\_i$$
Looking modulo $27$ and $17$, we find
$$t\_i\equiv 0\pmod{27}\Leftrightarrow i\equiv 3\pmod 9\Leftrightarrow t\_i\equiv 0\pmod{17}$$
It follows that the only powers of $3$ in the sequence $t\_i$ are $1,9$ which correspond to solutions $(1,1),(5,11)$.


So all the solutions are $(1,1),(2,2),(5,11)$.


Edit: This is a solution for positive integers. If we allow nonpositive integers, we also get $(0,0)$ and $(1,-1),(2,-2),(5,-11)$, but rather clearly no more.


