Find all positive integers $n$ such that there exists a prime number $p$, such that

$$
p^{n}-(p-1)^{n}
$$

is a power of 3.

Note. A power of 3 is a number of the form $3^{a}$ where $a$ is a positive integer.
Suppose that the positive integer $n$ is such that

$$
p^{n}-(p-1)^{n}=3^{a}
$$

for some prime $p$ and positive integer $a$.

If $p=2$, then $2^{n}-1=3^{a}$ by $(1)$, whence $(-1)^{n}-1 \equiv 0(\bmod 3)$, so $n$ should be even. Setting $n=2 s$ we obtain $\left(2^{s}-1\right)\left(2^{s}+1\right)=3^{a}$. It follows that $2^{s}-1$ and $2^{s}+1$ are both powers of 3, but since they are both odd, they are co-prime, and we have $2^{s}-1=1$, i.e. $s=1$ and $n=2$. If $p=3$, then (1) gives $3 \mid 2^{n}$, which is impossible.

Let $p \geq 5$. Then it follows from (1) that we can not have $3 \mid p-1$. This means that $2^{n}-1 \equiv 0$ $(\bmod 3)$, so $n$ should be even, and let $n=2 k$. Then

$$
p^{2 k}-(p-1)^{2 k}=3^{a} \Longleftrightarrow\left(p^{k}-(p-1)^{k}\right)\left(p^{k}+(p-1)^{k}\right)=3^{a}
$$

If $d=\left(p^{k}-(p-1)^{k}, p^{k}+(p-1)^{k}\right)$, then $d \mid 2 p^{k}$. However, both numbers are powers of 3, so $d=1$ and $p^{k}-(p-1)^{k}=1, p^{k}+(p-1)^{k}=3^{a}$.

If $k=1$, then $n=2$ and we can take $p=5$. For $k \geq 2$ we have $1=p^{k}-(p-1)^{k} \geq p^{2}-(p-1)^{2}$ (this inequality is equivalent to $p^{2}\left(p^{k-2}-1\right) \geq(p-1)^{2}\left((p-1)^{k-2}-1\right)$, which is obviously true). Then $1 \geq p^{2}-(p-1)^{2}=2 p-1 \geq 9$, which is absurd.

It follows that the only solution is $n=2$.