How many multiplications are performed when the following code fragment is executed? Express your answers in terms of $n$, where $n \geq 10$.
for(i = 0; i < 8; i++) for(j= i+1; j < n; j++) a[i][j] = a[i][j]*0.001;
With a little trial and error I can see that $8n - 36$ seems to work when $n \geq 10$, but I was curious on how to derive it. I understand that you get a double summation and simplify in terms of $N$, but the inner loop is throwing me off as I've never done double summation with an extra variable.
Work it out from the inside summation.
$\sum_{i=0}^7 \sum_{j=i+1}^{n-1} 1 = \sum_{i=0}^7 (n-1-i) = 8(n-1)-(0+\cdots+7)$.