Example 6. Using three different numbers from the set $S=\{1,2, \cdots, n\}(n>3)$ as side lengths, how many different triangles can be formed?
Let $T_{\mathrm{n}}$ be the number we are looking for, then $T_{\mathrm{n}}+{ }_{1}$ is the corresponding number for the set $S \cup\{n+1\}$. Consider $\Gamma_{n}+1-T_{n}$, it represents the number of triangles with one side length $n+1$ and the other two sides being different numbers from $S$. For each such triangle, the sum of the lengths of the two sides not equal to $n+1$ is one of the following numbers:
$$
2 n-1,2 n-2, \cdots, n+3, n+2
$$
(there are $n-2$ such numbers).
The number of triangles with these sums are respectively
$$
\begin{array}{l}
1,1,2,2,3,3, \cdots \text {, up to } n-2 \text { terms } \\
(\because 2 n-i=n+(n-i)=(n-1)+(n-i \\
+1)=(n-2)+(n-i+2)=\cdots) \text {, so, } \\
T_{\mathrm{n}+1}-T_{\mathrm{n}} \\
=1+1+2+2+3+3+\cdots \text { (up to } n-2 \text { terms), } \\
=\left\{\begin{array}{ll}
\frac{1}{4} n(n-2), & \text { ( } n \text { is even }) \\
\frac{1}{4}(n-1)^{2} . & (n \text { is odd) }
\end{array}\right. \\
\end{array}
$$

Thus, $T_{2 \tau}-T_{2 \mathrm{r}-2}$
$$
\begin{array}{l}
=\left(T_{2 r}-T_{2 r-1}\right)+\left(T_{2 r-1} \cdots T_{2 r}\right) \\
=(r \cdots 1)^{2}+(r-1)(r-2) \\
=2 r^{2}-5 r+3 .
\end{array}
$$

Substituting $r$ with $r-1, r-2, \cdots, 4,3$ in (1) and adding all the resulting equations, we get
$$
\begin{array}{l}
T_{2 \tau}-T_{4}=2 \cdot \frac{1}{6} r(r+1)(2 r+1) \\
-5 \cdot r(r+1)+3 r-\left(2 \times 2^{2}-5 \times 2+1\right) \\
=\frac{1}{6} r(r-1)(4 r-5)-1 .
\end{array}
$$

Clearly, $T_{4}=1$ (only 2, 3 form a triangle, 1 cannot form a triangle with any two of 2, 3, 4). Therefore,
$$
T_{2 r}=\frac{1}{6} r(r-1)(4 r-5) .
$$

From this, $T_{2 r+1}=T_{2 r}+r(r-1)$
$$
=\frac{1}{6} r(r-1)(4 r+1) \text {, }
$$

i.e., $T_{\mathrm{D}}=\left(\begin{array}{l}\frac{1}{24} n(n-2)(2 n-5),(n=2 r) \\ \frac{1}{24}(n-1)(n-3)(2 n-1),\end{array}\right.$
$$
(n=2 r+1) \text {. }
$$