Example 6 For an integer $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 Problem)
Let's solve the problem: When $n \geqslant 4$, for the set $M=\{m, m+1, m+2, \cdots, m+n-1\}$, if $m$ is odd, then $m, m+1, m+2$ are pairwise coprime; if $m$ is even, then $m+1, m+2, m+3$ are pairwise coprime. Thus, every $n$-element subset of $M$ contains at least 3 pairwise coprime numbers, so $f(n)$ exists and $f(n) \leqslant n$.

Let $T_{n}=\{t \mid t \leqslant n+1$, and $2 \mid t$ or $3 \mid t\}$. Then $T_{n}$ is a subset of $\{2,3, \cdots, n+1\}$, but any 3 numbers in $T_{n}$ are not pairwise coprime, so $f(n) \geqslant\left|T_{n}\right|+1$.

By the principle of inclusion-exclusion, $\left|T_{n}\right|=\left[\frac{n+1}{2}\right]+\left[\frac{n+1}{3}\right]-\left[\frac{n+1}{6}\right]+1$, so $f(n) \geqslant \left[\frac{n+1}{2}\right]+\left[\frac{n+1}{3}\right]-\left[\frac{n+1}{6}\right]+1$.

Moreover, note that $\{m, m+1, m+2, \cdots, m+n\}=\{m, m+1, m+2, \cdots, m+n-1\} \cup\{m+n\}$, so $f(n+1) \leqslant f(n)+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$.
We will now prove that $f(6)=5$.
Let $x_{1}, x_{2}, x_{3}, x_{4}, x_{5} \in\{m, m+1, m+2, \cdots, m+5\}$, and let $x_{i}(1 \leqslant i \leqslant 5)$ contain $k$ odd numbers.

Since $\{m, m+1, m+2, \cdots, m+5\}$ contains at most 3 even numbers, $x_{1}, x_{2}, x_{3}, x_{4}, x_{5}$ contain at most 3 even numbers, so $k \geqslant 2$.

Since $\{m, m+1, m+2, \cdots, m+5\}$ contains at most 3 odd numbers, $x_{1}, x_{2}, x_{3}, x_{4}, x_{5}$ contain at most 3 odd numbers, so $k \leqslant 3$.

If $k=3$, then the 3 odd numbers are pairwise coprime;
If $k=2$, then assume $x_{1}, x_{2}$ are odd, and $x_{3}, x_{4}, x_{5}$ are even. When $3 \leqslant i<j \leqslant 5$, $\left|x_{i}-x_{j}\right| \leqslant(m+5)-m=5$, but $x_{i}-x_{j}$ is even, so $\left|x_{i}-x_{j}\right|=2$ or 4, thus $x_{i} \equiv x_{j}(\bmod 3), x_{i} \equiv x_{j}(\bmod 5)$. Therefore, $x_{3}, x_{4}, x_{5}$ have at most 1 multiple of 3 and at most 1 multiple of 5, so at least 1 is neither a multiple of 3 nor 5. Let this number be $x_{3}$.

Consider the 3 numbers $x_{1}, x_{2}, x_{3}$. Since $1 \leqslant i<j \leqslant 3$, $\left|x_{i}-x_{j}\right| \leqslant(m+5)-m=5$, the greatest common divisor of $x_{i}$ and $x_{j}$ is at most 5, but $x_{3}$ is neither a multiple of 3 nor 5, so $\left(x_{1}, x_{3}\right)=\left(x_{2}, x_{3}\right)=1$. Also, $x_{1}-x_{2}$ is even, so $\left|x_{1}-x_{2}\right|=2$ or 4, thus $\left(x_{1}, x_{2}\right)=1$, meaning $x_{1}, x_{2}, x_{3}$ are pairwise coprime. Therefore, $f(6)=5$.

Since $f(7) \geqslant 6$ and $f(7) \leqslant f(6)+1=5+1=6$, we have $f(7)=6$.
Similarly, $f(8)=7, f(9)=8$.
This shows that for $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$$

We will now use mathematical induction to prove that (1) holds for all integers greater than 3.
Assume (1) holds for $n \leqslant k(k \geqslant 9)$. For $n=k+1$, since $\{m, m+1, m+2, \cdots, m+k\}=\{m, m+1, m+2, \cdots, m+k-6\} \cup\{m+k-5, m+k-4, \cdots, m+k\}$, we have $f(k+1) \leqslant f(k-5)+f(6)-1$. By the induction hypothesis,
$$\begin{aligned}
f(k+1) \leqslant & \left(\left[\frac{k-5+1}{2}\right]+\left[\frac{k-5+1}{3}\right]-\left[\frac{k-5+1}{6}\right]+1\right)+ \\
& \left(\left[\frac{6+1}{2}\right]+\left[\frac{6+1}{3}\right]-\left[\frac{6+1}{6}\right]+1\right)-1 \\
= & \left(\left[\frac{k}{2}\right]-2+\left[\frac{k-1}{3}\right]-1-\left[\frac{k-4}{6}\right]+1\right)+(3+2-1+1)-1 \\
= & \left(\left[\frac{k}{2}\right]+1+\left[\frac{k-1}{3}\right]+1-\left[\frac{k-4}{6}\right]-1\right)+1 \\
= & \left[\frac{k+2}{2}\right]+\left[\frac{k+2}{3}\right]-\left[\frac{k+2}{6}\right]+1, \text{ (1) holds. }
\end{aligned}$$

Therefore, for all integers greater than 3, $f(n)=\left[\frac{n+1}{2}\right]+\left[\frac{n+1}{3}\right]-\left[\frac{n+1}{6}\right]+1$.