In this question the key point is that k will be increased by 1 everytime because of the for loop.
Then in the while loop K is increased by logn. n is the constant we set. We assume the time it runs in the while loop is t. So the while loop will run like 1+t*logn <= n, t = (n-1)/logn for the first time.
In the second time 2+t*logn <=n
so t <= (n-2)/logn
in the last time for the for loop, t<=(n-(n-1))/logn
sum of the t is (1+2+3+...(n-2)+(n-1))/logn = n(n-1)/2*logn = O(n2/logn)
also for all here is the question that how can i simplify O(n2/logn) further?
Hope i think it right