I came from the programming world, i saw an exercise: "Calculate the average of a list of numbers in a functional way", then i saw an interesting answer after provide my solution.
So, lets say i have this list: $\{2, 4, 6, 8, 10\}$ I want to calculate the average, so that solution proceeded as next:
$$ \text{avg} = \frac{2 - \mathbf{0}}{1} + \frac{4 - \mathbf{2}}{2} + \frac{6 - \mathbf{3}}{3} + \frac{8 - \mathbf{4}}{4} + \frac{10 - \mathbf{5}}{5} $$
So we can say, starting from $\text{currentAverage} = 0$ and starting $\text{index} = 1 \in \{1,2,3,4,5\}$, we can calculate the average as next: $$ \sum_{i=1}^n \text{currentAverage} + \frac{(n_i - \text{currentAverage})}{\text{index}_i} $$
Where did this deduction come from? Thanks!