int f2(int n)
{
int x, y, z = 0, i;
for(x = n, i = 0; i < n; i ++, x *= n)
{
y = x;
while (y > 1)
{
y /= 3;
z += y;
}
}
return z;
}
I get confused by the first loop and my problem is that I can’t figure out how many times the loop is executed and how x
influences
the code in general.
It's:
log3(n) + log3(n2) + ... + log3(nn) = log3(n)n(n+1)/2
in short term: