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.
To solve the problem, we need to find all positive integers \( n \) such that there exists a prime number \( p \) for which \( p^n - (p-1)^n \) is a power of 3. Let's go through the solution step-by-step.

1. **Initial Considerations:**
   - We are given that \( p^n - (p-1)^n \) is a power of 3, i.e., \( p^n - (p-1)^n = 3^a \) for some positive integer \( a \).
   - Since \( 3^0 = 1 \) is not considered a power of 3, we have \( n > 1 \).

2. **Modulo 3 Analysis:**
   - Consider the expression modulo 3. If \( p \equiv 0 \pmod{3} \), then \( p \) is divisible by 3, which is not possible since \( p \) is a prime number.
   - If \( p \equiv 1 \pmod{3} \), then \( p-1 \equiv 0 \pmod{3} \), making \( (p-1)^n \equiv 0 \pmod{3} \). Thus, \( p^n \equiv 3^a \pmod{3} \), which is not possible since \( p^n \equiv 1 \pmod{3} \) and \( 3^a \equiv 0 \pmod{3} \).
   - Therefore, \( p \equiv 2 \pmod{3} \).

3. **Simplifying the Expression:**
   - Given \( p \equiv 2 \pmod{3} \), we have \( p-1 \equiv 1 \pmod{3} \).
   - Thus, \( p^n \equiv 2^n \pmod{3} \) and \( (p-1)^n \equiv 1^n \equiv 1 \pmod{3} \).
   - Therefore, \( p^n - (p-1)^n \equiv 2^n - 1 \equiv 0 \pmod{3} \), which implies \( 2^n \equiv 1 \pmod{3} \).

4. **Determining \( n \):**
   - The congruence \( 2^n \equiv 1 \pmod{3} \) holds if and only if \( n \) is even. Let \( n = 2k \).

5. **Further Analysis for \( n = 2k \):**
   - Consider \( n = 4m \) (i.e., \( n \) is a multiple of 4). We have:
     \[
     p^4 - (p-1)^4 = (p^2 - (p-1)^2)(p^2 + (p-1)^2)
     \]
   - Simplifying, we get:
     \[
     p^2 - (p-1)^2 = p^2 - (p^2 - 2p + 1) = 2p - 1
     \]
     \[
     p^2 + (p-1)^2 = p^2 + (p^2 - 2p + 1) = 2p^2 - 2p + 1
     \]
   - Since \( p \equiv 2 \pmod{3} \), we have:
     \[
     p^2 \equiv 4 \equiv 1 \pmod{3} \quad \text{and} \quad (p-1)^2 \equiv 1 \pmod{3}
     \]
   - Thus, \( p^2 + (p-1)^2 \equiv 1 + 1 \equiv 2 \pmod{3} \), which cannot be a power of 3.

6. **Conclusion for \( n = 2k \):**
   - Since \( n = 4m \) is not possible, we must have \( n = 2k \) where \( k \) is odd.
   - If \( k > 1 \), then \( p^k - (p-1)^k \) must also be a power of 3, which is not possible by our previous analysis.
   - Therefore, \( k = 1 \), and \( n = 2 \).

7. **Verification:**
   - For \( n = 2 \), we have:
     \[
     p^2 - (p-1)^2 = p^2 - (p^2 - 2p + 1) = 2p - 1
     \]
   - We need \( 2p - 1 = 3^a \). For \( a = 1 \), we get \( 2p - 1 = 3 \implies 2p = 4 \implies p = 2 \), which is a prime number.
   - For \( p = 2 \), we have \( 2^2 - 1^2 = 4 - 1 = 3 = 3^1 \), which is indeed a power of 3.

Thus, the only solution is \( n = 2 \).

The final answer is \( \boxed{n = 2} \).