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 = 1; i < n; i = i + 2) for(j= 0; j <= i; j++) a[i][j] = a[i][j]*0.001;
Would anyone be able to help me solve it with steps included? I did some other examples and solved them using a double summation, but my algebra skills are lacking when variables are introduced in the inner loop.
The first loop is over all odd integers less than $n$. The second loop is over all integers from $0$ to $i$. There is one multiplication in the inner loop. This gives us that the total number of multiplications is $$2 + 4 + 6 + \ldots + 2\left\lfloor\frac{n}{2}\right\rfloor = 2\left(1+2+\ldots+\left\lfloor\frac{n}{2}\right\rfloor\right) = \left\lfloor\frac{n}{2}\right\rfloor\left(\left\lfloor\frac{n}{2}\right\rfloor+1\right)$$
Explanation: $2$ multiplications for $i=1$ $(j=0,1$), $4$ multiplications for $i=3$ $(j=0,1,2,3)$, and so on up to $n$. Above I have used the formula for the sum of the first $n$ integers.