Shouldn't this be O(n^4)?

for each i,
k runs n*n(n-1)/2 times
thus, for i == n

time = O(n * n*n(n-1)/2) = O(n^4)

please paste the question here