Example 7 Divide $n$ stones into two piles at random, and record the product of the number of stones in the two piles; then divide one of the piles into two piles, and record the product of the number of stones in these two piles; then divide one of the three piles into two piles, and record the product of the number of stones in these two piles; continue this process until the stones are divided into $n$ piles, each containing one stone. Find the sum of these products.
When dividing into two piles, there is one product; when dividing into three piles, there are two products; $\cdots$; when dividing into $n$ piles, there are $n-1$ products. Now, we seek the sum of these $n-1$ products, denoted as $S(n)$.
When $n=2$, $S(2)=1 \times 1=1=\frac{2 \times 1}{2}$
When $n=3$, $S(3)=1 \times 2+1 \times 1=3=\frac{3 \times 2}{2}$
When $n=4$, $S(4)=2 \times 2+1 \times 1+1 \times 1=6=\frac{4 \times 3}{2}$
$\qquad$
Based on this, we conjecture that $S(n)=\frac{n(n-1)}{2}$. We will prove this using mathematical induction.
Assume that for $2 \leqslant n \leqslant k$, we have $S(n)=\frac{n(n-1)}{2}$. Then, when $n=k+1$, first divide $k+1$ stones into two piles with $m$ and $k+1-m$ stones, where $1 \leqslant m \leqslant k, m \in \mathbf{N}$. By symmetry, we can assume $1 \leqslant m \leqslant \frac{k+1}{2}$
If $m=1$, then $S(k+1)=1 \cdot k+S(k)=k+\frac{k(k-1)}{2}=\frac{(k+1) k}{2}$
If $m>1$, then $S(k+1)=m(k+1-m)+S(m)+S(k+1-m)$
$$
=m(k+1-m)+\frac{m(m-1)}{2}+\frac{(k+1-m)(k-m)}{2}=\frac{(k+1) k}{2}
$$

Therefore, $S(n)=\frac{n(n-1)}{2}$ holds for all natural numbers $n$ greater than or equal to 2. This is the solution to the problem.