If I have the following:
$$(1 * 1) + (2 * 2) + (3 * 3) + (4 * 4) + (5 * 5) + (6 * 6) = 91$$
Is the average $\frac{91}{6} = 15.16$ because I have $6$ distinct numbers that are being squared and then summed, or is it $\frac{91}{12} = 7.58$ because I squared and summed up $12$ numbers? I'm writing a program to calculate this. It's more about getting a for loop to work a certain way than it is about the math. The for loop increments one number at a time. I know I could put something in the comments as to how I'm coming up with this but I'm curious as to which would be more correct.
The correct divisor is $6$. To get the average, it doesn't matter how you got the terms. Another way to get the squares is to add up the odd numbers, so you could do $\frac 16\left((1)+(1+3)+(1+3+5)+(1+3+5+7)+(1+3+5+7+9)+(1+3+5+7+9+11)\right)$ You wouldn't want the denominator to change to $21$ because you got the squares this way, would you?