Looking for help on how to find time complexity here:
void f(int n)
{
for(int i=0; i<n; ++i)
for(int j=0; j<i; ++j)
for(int k=i*j; k>0; k/=2)
printf("~");
}
What I tried so far is noticing the inner loop runs log(i*j)
times for O(1)
for each received combination of i,j
. So I got:
log(n(n-1))+log(n(n-2))+...+log(n)+log((n-1)(n-2))+...+log(n-1)+...+...+log(1) but I can't find how to simplify it.