void function(int n)
{
int count = 0;
for (int i=0; i<n; i++)
{
for (int j=1; j< i*i; j++)
{
if (j%i == 0)
{
for (int k=0; k<j; k++)
printf("*");
}
}
}
}
Here the innermost loop will run maximum when
j=(n^2)-1
so the T.C of innermost loop will be = O(n^2)
now the middle loop
i.e for (int j=1; j< i*i; j++)
this will run maximum when i=n-1
and as the constraint here is j<i*i thus T.C = O(n^2)
now coming to the outermost loop it is clearly running n times
thus T.C = O(n)
the overall T.C = n*n^2*n^2
it will be O(n^5).