Here I have a loop:
for (i = n; i < 2*n; i += 4) {
for (j = 0; j < 3*i; j += 2) {
function();
}
}
How can I count the number of calls (in terms of n) of function () without running this code?
As an idea, I think I can use an arithmetic progression, which has the sum S = (a1 + ak) * k / 2, where a1 is the number of iterations of the inner loop, while I have the initial value, ak is the number of iterations of the inner loop , while I have a finite meaning.
But I can not express it as one formula with n as a variable.
Do you have any ideas about this?
source
share