I'm wondering why is the tightest Big-Oh Complexity of the following code O(n^4) instead of O(n^5):
int sum = 0;
for(int i=1; i<n ; i++){ //O(n)
for(int j=1; j<i*i; j++){ // O(n^2)
if(j%i == 0)
for(int k=0; k<j; k++) //O(n^2)
sum++;
}
}
Can anyone help me with this? Thank you!