18 Coprime positive integers $p_{n}, q_{n}$ satisfy $\frac{p_{n}}{q_{n}}=1+\frac{1}{2}+\frac{1}{3}+\cdots+\frac{1}{n}$, find all positive integers $n$, such that $3 \mid p_{n}$.
Express $n$ in ternary:
$$
n=\left(a_{k} a_{k-1} \cdots a_{0}\right)_{3}=a_{k} \cdot 3^{k}+\cdots+a_{1} \cdot 3^{1}+a_{0},
$$

where $a_{j} \in\{0,1,2\}, j=0,1,2, \cdots, k, a_{k} \neq 0$.
Let $A_{n}$ denote the least common multiple of $1,2, \cdots, n$, then $A_{n}=3^{k} \cdot B_{n}, 3 \nmid B_{n}$.
Let $L_{n}=A_{n} \cdot \frac{p_{n}}{q_{n}}=A_{n}\left(1+\frac{1}{2}+\cdots+\frac{1}{n}\right)$,

then $L_{n} \in \mathbf{N}_{+}$, and $\quad 3\left|p_{n} \Leftrightarrow 3^{k+1}\right| L_{n}$.
Let $\quad S_{j}=\sum_{\substack{1 \leqslant i \leqslant \frac{n}{\xi^{3}} \\ 3 i_{i}}} \frac{1}{i}, j=0,1,2, \cdots, k$.

Then
$$
\begin{aligned}
L_{n} & =3^{k} \cdot B_{n} \cdot \sum_{1 \leqslant i \leqslant n} \frac{1}{i} \\
& =B_{n} \cdot S_{k}+3^{1} \cdot B_{n} \cdot S_{k-1}+\cdots+3^{k} \cdot B_{n} \cdot S_{0} .
\end{aligned}
$$

Lemma: When $a_{j}=0$ or 2, $B_{n} \cdot S_{j} \equiv 0(\bmod 3)$;
when $a_{j}=1$, $B_{n} \cdot S_{j} \equiv B_{n}(\bmod 3)$.
Proof: Since $\frac{1}{3 m+1}+\frac{1}{3 m+2}=\frac{3(2 m+1)}{(3 m+1)(3 m+2)}$,
we have
$$
B_{n} \cdot\left(\frac{1}{3 m+1}+\frac{1}{3 m+2}\right) \equiv 0(\bmod 3) \text {. }
$$

Therefore, when $a_{j}=0$ or 2, $B_{n} \cdot S_{j} \equiv 0(\bmod 3)$; when $a_{j}=1$,
$$
B_{n} S_{j} \equiv \frac{B_{n}}{3 r+1} \equiv B_{n}(\bmod 3) .
$$

Returning to the original problem, assume $3^{k+1} \mid L_{n}$. From (*) we get $B_{n} S_{k} \equiv 0(\bmod 3)$.
By the lemma, we know $a_{k}=2, S_{k}=\frac{3}{2}$. If $k=0$, then $n=2$.
When $k \geqslant 1$, from (*) we get
$$
0 \equiv B_{n} \cdot \frac{3}{2}+3^{1} \cdot B_{n} \cdot S_{k-1}(\bmod 9),
$$
then
$$
0 \equiv B_{n} \cdot S_{k-1}+B_{n} \cdot \frac{1}{2} \equiv B_{n} \cdot S_{k-1}-B_{n}(\bmod 3),
$$

hence
$$
B_{n} \cdot S_{k-1} \equiv B_{n}(\bmod 3) \text {. }
$$

By the lemma, we know $a_{k-1}=1, S_{k-1}=1+\frac{1}{2}+\frac{1}{4}+\frac{1}{5}+\frac{1}{7}$.
If $k=1$, then $n=(2,1)_{3}=7$.
When $k \geqslant 2$, from (*) we get
$$
0 \equiv B_{n} \cdot \frac{3}{2}+3^{1} \cdot B_{n} \cdot S_{k-1}+3^{2} \cdot B_{n} \cdot S_{k-2}(\bmod 27),
$$

then
$$
\begin{aligned}
0 & \equiv 3 \cdot B_{n} \cdot S_{k-2}+B_{n} \cdot \frac{1}{2}+B_{n} \cdot\left(1+\frac{1}{2}+\frac{1}{4}+\frac{1}{5}+\frac{1}{7}\right) \\
& \equiv 3 \cdot B_{n} \cdot S_{k-2}+B_{n} \cdot\left(2+\frac{1}{4}+\frac{1}{5}+\frac{1}{7}\right) \\
& \equiv 3 \cdot B_{n} \cdot S_{k-2}+B_{n}(2-2+2+4) \\
& \equiv 3 \cdot\left(B_{n} \cdot S_{k-2}-B_{n}\right)(\bmod 9)
\end{aligned}
$$

hence
$$
B_{n} \cdot S_{k-2} \equiv B_{n}(\bmod 3) .
$$

By the lemma, we know $a_{k-2}=1, S_{k-2}=1+\frac{1}{2}+\frac{1}{4}+\cdots+\frac{1}{22}$.
If $k \geqslant 3$, from (*) we get
$$
\begin{aligned}
0 \equiv & B_{n} \cdot \frac{3}{2}+3^{1} \cdot B_{n} \cdot\left(1+\frac{1}{2}+\frac{1}{4}+\frac{1}{5}+\frac{1}{7}\right) \\
& +3^{2} \cdot B_{n} \cdot S_{k-2}+3^{3} \cdot B_{n} \cdot S_{k-3}(\bmod 81),
\end{aligned}
$$

then
$$
\begin{aligned}
0 & \equiv B_{n}\left(2+\frac{1}{4}+\frac{1}{5}+\frac{1}{7}\right)+3 \cdot B_{n} \cdot S_{k-2}+3^{2} \cdot B_{n} \cdot S_{k-3} \\
& \equiv B_{n}(2+7+11+4)+3 \cdot B_{n} \cdot S_{k-2}+3^{2} \cdot B_{n} \cdot S_{k-3} \\
& \equiv-3 \cdot B_{n}+3 \cdot B_{n} \cdot S_{k-2}+3^{2} \cdot B_{n} \cdot S_{k-3}(\bmod 27),
\end{aligned}
$$

thus $0 \equiv 3 \cdot B_{n} \cdot S_{k-3}+B_{n}\left(-1+1+\frac{1}{2}+\frac{1}{4}+\cdots+\frac{1}{22}\right)$
$$
\begin{aligned}
\equiv & 3 \cdot B_{n} \cdot S_{k-3}+B_{n}\left[-1+\left(1+\frac{1}{2}+\frac{1}{4}-\frac{1}{4}-\frac{1}{2}\right.\right. \\
& \left.-1) \times 2+\left(1+\frac{1}{2}+\frac{1}{4}\right)\right] \\
\equiv & 3 \cdot B_{n} \cdot S_{k-3}+B_{n}(5-2) \\
\equiv & 3 \cdot B_{n} \cdot S_{k-3}+3 \cdot B_{n}(\bmod 9) .
\end{aligned}
$$

Hence $B_{n} \cdot S_{k-3}+B_{n} \equiv 0(\bmod 3)$, by the lemma, this is impossible.
Therefore, the positive integers $n$ are 2, 7, and 22.