Given $n$ sticks, their lengths are $1,2,3, \ldots, n$ units. How many true triangles can be formed from them by joining the ends of three sticks?
Let $V_{n}$ denote the number of triangles that can be formed from unit rods of lengths $1,2, \ldots, n$, and let $S_{k}$ be the number of these triangles in which the longest rod is $k$ units long. Then

$$
V_{n}=S_{1}+S_{2}+\ldots+S_{n}=S_{3}+S_{4}+\ldots+S_{n}
$$

since $S_{n}=S_{2}=0$ (although $S_{3}$ is also 0, we write this term for the sake of later considerations).

Let us denote the lengths of the other two sides of a triangle, in which the longest side is $k$ units, by $a$ and $b$ such that

$$
k>a>b \geq 1
$$

Thus, $a$ and $b$ are natural numbers, and according to the triangle inequality,

$$
a+b>k
$$

If the natural numbers $a$ and $b$ satisfy (2) and (3), then there is a triangle whose sides are $a, b$, and $k$ units long, since the triangle inequality for the other two sides trivially holds due to (2). Therefore, $S_{k}$ is equal to the number of solutions to the system of inequalities (2) - (3) in the set of natural numbers.

If the pairs $(a, b)$ are plotted in a Cartesian coordinate system, the points lie within the square $N_{k}$ defined by the inequalities

$$
1 \leq a<k, \quad 1 \leq b<k
$$

below the line $e$ where $a=b$ and to the right of the line $f$ where $a+b=k$. $S_{k}$ is the number of lattice points (points with integer coordinates) in this region of the plane.

![](https://cdn.mathpix.com/cropped/2024_05_02_0ac554ecd827060f22dcg-1.jpg?height=564&width=602&top_left_y=1062&top_left_x=751)

There are $(k-1)$ integer-coordinate points on each side of the square $N_{k}$, so there are $(k-1)^{2}$ lattice points in $N_{k}$. We need to subtract the number of lattice points on the lines $e$ and $f$, each of which also has $(k-1)$ lattice points. However, if the coordinates of the intersection point $C$ of the lines $e$ and $f$ are integers, this point would be counted twice. The coordinates of $C$, $k / 2$, are integers if and only if $k$ is even. Therefore, if we exclude the points on the lines $e$ and $f$ from $N_{k}$, the number of remaining lattice points is

$$
(k-1)^{2}-2(k-1)+\lambda_{k}=(k-2)^{2}-\mu_{k}
$$

where $\lambda_{k}=1$ if $k$ is even, and $\lambda_{k}=0$ if $k$ is odd, and $\mu_{k}=1-\lambda_{k}$. The lines $e$ and $f$ divide the square $N_{k}$ into four congruent regions, each containing an equal number of lattice points, since reflecting any lattice point across these lines results in another lattice point. Therefore,

$$
S_{k}=\frac{1}{4}\left((k-2)^{2}-\mu_{k}\right)
$$

If $n$ is odd, then considering (1),

$$
4 V_{n}=\sum_{k=3}^{n}(k-2)^{2}-\sum_{k=3}^{n} \mu_{k}
$$

where the second sum is the number of odd numbers between 3 and $n$, since $\mu_{k}=1$ if $k$ is odd, and $\mu_{k}=0$ if $k$ is even. Thus, this second sum is equal to half of $(n-1)$ and

$$
\begin{aligned}
4 V_{n} & =\sum_{k=1}^{n-2} k^{2}-\frac{n-1}{2}=\frac{(n-2)(n-1)(2 n-3)}{6}-\frac{n-1}{2}= \\
& =\frac{n-1}{6}\left(2 n^{2}-7 n+3\right)=\frac{(n-1)(n-3)(2 n-1)}{6}
\end{aligned}
$$

Thus, for odd $n$,

$$
V_{n}=\frac{(n-1)(n-3)(2 n-1)}{24}
$$

If $n$ is even, then using this and (4), we get

$$
\begin{aligned}
V_{n} & =V_{n+1}-S_{n+1}=\frac{n(n-2)(2 n+1)}{24}-\frac{(n-1)^{2}-1}{4}= \\
& =\frac{n(n-2)(2 n+1)}{24}-\frac{n(n-2)}{4}=\frac{n(n-2)(2 n-5)}{24}
\end{aligned}
$$

The two expressions can be combined. The two numerators, after multiplication, are

$$
2 n^{3}-9 n^{2}+10 n-3, \quad \text { or } \quad 2 n^{3}-9 n^{2}+10 n
$$

Thus, for all $n$ (with $n \geq 3$), using the floor function,

$$
V_{n}=\left[\frac{n(n-2)(2 n-5)}{24}\right]
$$