Solution:
Suppose that the positive integer n is such that
pn−(p−1)n=3a
for some prime p and positive integer a.
If p=2, then 2n−1=3a by (1), whence (−1)n−1≡0(mod3), so n should be even. Setting n=2s we obtain (2s−1)(2s+1)=3a. It follows that 2s−1 and 2s+1 are both powers of 3, but since they are both odd, they are co-prime, and we have 2s−1=1, i.e. s=1 and n=2.
If p=3, then (1) gives 3∣2n, which is impossible.
Let p≥5. Then it follows from (1) that we can not have 3∣p−1. This means that 2n−1≡0 (mod3), so n should be even, and let n=2k. Then
p2k−(p−1)2k=3a⟺(pk−(p−1)k)(pk+(p−1)k)=3a
If d=(pk−(p−1)k,pk+(p−1)k), then d∣2pk. However, both numbers are powers of 3, so d=1 and pk−(p−1)k=1, pk+(p−1)k=3a.
If k=1, then n=2 and we can take p=5. For k≥2 we have 1=pk−(p−1)k≥p2−(p−1)2 (this inequality is equivalent to p2(pk−2−1)≥(p−1)2((p−1)k−2−1), which is obviously true). Then 1≥p2−(p−1)2=2p−1≥9, which is absurd.
It follows that the only solution is n=2.