Time complexity of Q2

   void function(int n) 
   { 
     int count = 0; 

     for (int i=0; i<n; i++) 
     for (int j=i; j< i*i; j++) 
         if (j%i == 0) 
         { 
            for (int k=0; k<j; k++) 
                 printf("*"); 
          } 
    } 

How to compute time complexity of the above code. Can you list the steps.

Consider the comments in the following function.

void function(int n)
{

int count = 0; 

// executes n times 
for (int i=0; i<n; i++) 

    // executes O(n*n) times. 
    for (int j=i; j< i*i; j++) 
        if (j%i == 0) 
        { 
            // executes j times = O(n*n) times 
            for (int k=0; k<j; k++) 
                printf("*"); 
        } 

}

Time Complexity of the above function O(n^5)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.