What is the average of $n(100-n)$ for $n \in {1,2,...,100}$
I saw this problem on the internet without a method of solving it without brute force or a computer. The answer is 1666.5.
If you were to integrate, you would get:
$$\int_0^{100} x(100-x)dx = \frac{500000}{3}$$
which gives $\frac{5000}{3}$ for the average, but $\frac{5000}{3} \neq 1666.5$.
So I thought of an analogues problem which is: “what is the sum of $1+2+…+100$”
For which we have:
$$\sum_{i=1}^1 1 + \sum_{i=1}^2 1 + … + \sum_{i=1}^{100} 100$$
If we extend the summations upwards, we would have a triangle with a height of 100 and base of 100. Then we just solve for the area treating each 1 as a unit 1 square block. But since we the have a Riemann sum, we have to consider that the triangle is cutting off the edges of the squares, so we have to add those too, which is: 100 half 1-unit square blocks = 50 units. Then the sum is equal to $\frac{base}{2} * height + 50 = 5050$.
The issue we have applying this to our problem is that the amount the integration is removing of the Riemann sum isn’t linear. It is symmetrical both sides, but for numbers close to 0 and 100, the integral cuts off more compare to when $n\approx 50$.
Is there a trick to get the solution without a using a computer or a really long brute-force method?
$$S := \sum_{n=1}^{100} n(100-n)$$ $$ = \sum_{n=1}^{100} (100n - n^2)$$ $$ = 100 \sum_{n=1}^{100} n - \sum_{n=1}^{100} n^2$$
If you know the formulas for sum of $n$ and sum of $n^2$,
$$\sum_{n=1}^{N} n = \frac{N(N+1)}{2}$$ $$\sum_{n=1}^{N} n^2 = \frac{N(N+1)(2N+1)}{6}$$
Then,
$$S = 100 \frac{100(101)}{2} - \frac{100(101)(201)}{6}$$ $$= 166650$$
To get the average, simply divide by $N=100$ to get $1666.5$.