Example 7 For an integer $n(n \geqslant 4)$, find the smallest integer $f(n)$ such that for any positive integer $m$, in any $f(n)$-element subset of the set $\{m, m+1, \cdots, m+n-1\}$, there are at least 3 pairwise coprime elements.
(2004, National High School Mathematics Competition)
Given the condition "for any positive integer $m$", we can take $m=2$. Then, in the set $S=\{2,3, \cdots, n+1\}$, the numbers divisible by 2 are $\left[\frac{n+1}{2}\right]$, the numbers divisible by 3 are $\left[\frac{n+1}{3}\right]$, and the numbers divisible by both 2 and 3 are $\left[\frac{n+1}{6}\right]$. Therefore, the number of elements in $S$ that are divisible by 2 or 3 is $\left[\frac{n+1}{2}\right]+\left[\frac{n+1}{3}\right]-\left[\frac{n+1}{6}\right]$.

Clearly, any three of these numbers cannot be pairwise coprime, so,
$$
f(n) \geqslant\left[\frac{n+1}{2}\right]+\left[\frac{n+1}{3}\right]-\left[\frac{n+1}{6}\right]+1 .
$$

Thus, $f(4) \geqslant 4, f(5) \geqslant 5, f(6) \geqslant 5$,
$$
f(7) \geqslant 6, f(8) \geqslant 7, f(9) \geqslant 8 \text {. }
$$

First, consider the simplest cases.
Clearly, $f(4)=4, f(5)=5$.

Next, we prove: $f(6)=5$.
Let $x_{1}, x_{2}, x_{3}, x_{4}, x_{5}$ be 5 numbers in $\{m, m+1, \cdots, m+5\}$.

If these 5 numbers include 3 odd numbers, then they are pairwise coprime.

If these 5 numbers include 2 odd numbers, then there must be 3 even numbers. Assume $x_{1}, x_{2}, x_{3}$ are even and $x_{4}, x_{5}$ are odd. If $1x_{3}$, then $x_{3}, x_{4}, x_{5}$ are pairwise coprime.
Thus, among these 5 numbers, there are 3 numbers that are pairwise coprime, i.e.,
$$
\begin{array}{l}
f(6)=5 . \\
\text { By }\{m, m+1, \cdots, m+n\} \\
=\{m, m+1, \cdots, m+n-1\} \cup\{m+n\},
\end{array}
$$

we know $f(n+1) \leqslant f(n)+1$.
Since $f(6)=5$, we have
$$
f(7)=6, f(8)=7, f(9)=8 \text {. }
$$

Therefore, when $4 \leqslant n \leqslant 9$,
$$
f(n)=\left[\frac{n+1}{2}\right]+\left[\frac{n+1}{3}\right]-\left[\frac{n+1}{6}\right]+1 \text {. }
$$

Secondly, we prove by mathematical induction that formula (2) holds for all $n$.
Assume that for $n \leqslant k(k \geqslant 9)$, formula (2) holds.
When $n=k+1$, since
$$
\begin{aligned}
& \{m, m+1, \cdots, m+k\} \\
= & \{m, m+1, \cdots, m+k-6\} \cup \\
& \{m+k-5, m+k-4, \cdots, m+k\},
\end{aligned}
$$

and by the induction hypothesis, for $n=6$ and $n=k-5$, formula (2) holds.
$$
\begin{array}{l}
\text { then } f(k+1) \leqslant f(k-5)+f(6)-1 \\
=\left[\frac{k-4}{2}\right]+\left[\frac{k-4}{3}\right]-\left[\frac{k-4}{6}\right]+1+5-1 \\
=\left[\frac{k+2}{2}\right]+\left[\frac{k+2}{3}\right]-\left[\frac{k+2}{6}\right]+1 .
\end{array}
$$

By formulas (1) and (3), for $n=k+1$, formula (2) holds.
Therefore, for any $n \geqslant 4$, formula (2) holds.