Attempting this by testing and graphics. The log2 vs log2 plot looks fairly linear. Something between more than linear O(n) and less than O(n*log(n)). "Draw" your own conclusion.
[Edit]
Using the mathematical derived formulas, the O() calculated is an upper bound of O(n * log(n)). That uses "fractions of loop iterations" that increase the count by a fraction and not 1. E.g. When n is 6, iteration count is 6 + 3 + 2 + 1.5 + 1.2 + 1 = 14.7 loops rather than actual 6 + 3 + 2 + 2 + 2 + 1 = 16. This difference is relatively less significant as n increases, thus the slightly less than O(n * log(n)) growth. So by not ignoring code uses integer math, we have a much more challenging question.
unsigned long long what(int n) {
unsigned long long cnt = 0;
int i;
for (i = 1; i <= n; i++) {
int x = n;
while (x > 0) {
x -= i;
cnt++;
}
}
return cnt;
}
void wtest(int n) {
unsigned long long cnt = what(n);
printf("%d %llu\n", n, cnt);
fflush(stdout);
}
void wtests(void) {
int i = INT_MAX/2 + 1;
while (i > 0) {
wtest(i);
i /= 2;
}
}
int main(void) {
wtests();
return 0;
}
Output
1073741824 23567395117
536870912 11411566988
268435456 5519718329
134217728 2666826555
67108864 1286897093
33554432 620190504
16777216 298466265
8388608 143418602
4194304 68802063
2097152 32947406
1048576 15746897
524288 7510048
262144 3573331
131072 1695816
65536 802493
32768 378537
16384 177921
8192 83286
4096 38803
2048 17973
1024 8275
512 3782
256 1713
128 765
64 337
32 145
16 61
8 24
4 9
2 3
1 1