retagged by
423 views

3 Answers

0 votes
0 votes

It think it's O(n4) because 

i will run n times

j will go till nbut it will be running only n times as from 1 to nyou will have n cases when j%i will be 0. For eg. say n=12 iteration is going on. n2 is 144. Now from 1 to 144, you will encounter 12 (n) cases like 12,24,36,48,etc. 

Coming to k, k goes till j and hence can go till nas value of j will go till n2

so n*n*n2 = n4

0 votes
0 votes
For i=1 ,j=1,k=1

for i=2 ,j=1 to 4 ,k=2+4=1(1+2)

for i=3,j=1 to 9 , k=3+6+9=3(1+2+3)

.

.

.overall summation = 1+2(1+2)+3(1+2+3)+.....+n(1+2+3+....+n)

=1.1+2.o(2^2)+3.o(3^2)+.....n.o(n2)

=summation of cubic series=o(n^4)

Related questions

0 votes
0 votes
1 answer
1
2 votes
2 votes
1 answer
2
gauravkc asked Apr 5, 2018
911 views
What is the time complexity of this code?
3 votes
3 votes
1 answer
3
0 votes
0 votes
1 answer
4