Let $n \ge 3$ be a natural number.
Determine the number $a_n$ of all subsets of $\{1, 2,...,n\}$ consisting of three elements such that one of them is the arithmetic mean of the other two.
Proposed by Walther Janous
We want to find the number of $3$-element subsets of $\{1,2,...,n\}$ which form an arithmetic sequence.
The number of subsets where the common difference is $1$ is equal to $n-2$.
The number of subsets where the common difference is $2$ is equal to $n-4$.
The number of subsets where the common difference is $3$ is equal to $n-6$, etc.
In general, the number of subsets where the common difference is $k$ is equal to $n-2k$. This means, the number of such $3$-element subsets is equal to:
$$\sum_{k=1}^{\lfloor\frac n2\rfloor}(n-2k)$$If $n$ is even, then this is equal to
$$\sum_{k=1}^{\frac n2}(n-2k)=\frac{n^2}4-\frac n2$$and if $n$ is odd, then this is equal to
$$\sum_{k=1}^{\frac{n-1}2}(n-2k)=\frac{n^2}4-\frac n2+\frac14$$The answer is
$$a_n=\begin{cases}\frac14n^2-\frac12n&(n\text{ is even})\\\frac14n^2-\frac12n+\frac14&(n\text{ is odd})\end{cases}$$
Let the subset is $\{x, y, z\}$ with $x<y<z$. Hence we have $y=\frac{x+z}{2}$. Since $y$ is integer then $x$ and $z$ must have same paritas. And note that for each pair $x$ and $z$ we will have unique value $y$ that satisfied the condition $y=\frac{x+z}{2}$. So the number of subsets is $\binom{\lfloor \frac{n}{2} \rfloor}{2}+\binom{\lceil \frac{n}{2} \rceil}{2}$