17. (2005 National Team Mathematics Training Question) 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}$.
17. Represent $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 $\quad 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 \times 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 $3\left|p_{n} \Leftrightarrow 3^{k+1}\right| L_{n}$.
Let $S_{j}=\sum_{\substack{1 \leqslant i \leqslant \frac{\pi}{3 j} \\ 3 \times i}} \frac{1}{i}, j=0,1,2, \cdots, k$, then
$$
L_{n}=3^{k} \cdot B_{n} \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} .
$$

Lemma: When $a_{j}=0$ or 2, $B_{i n} \cdot S_{j} \equiv 0(\bmod 3)$; when $a_{j}=1$, $B_{n} \cdot S_{j} \equiv B_{n}(\bmod 3)$.
In the context of number theory problems in mathematics:
Proof of the lemma: 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)$.
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) \text {, }
$$

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}+\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
$$
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),
$$

then $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}$
$$
\begin{array}{l}
\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{array}
$$

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}-1\right) \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.