This is O(n^3), since the constants and lower-order terms are discarded for time complexities.
If we didn't discard those things, it'd be (n - 2) * (n - 1)/2 * n/3. You can derive this equation yourself by doing the following:
int n = 1000;
int loop1 = 0, loop2 = 0, loop3 = 0;
for (int i = 1; i <= (n-2); i++){
loop1++;
for (int j = i+1; j<= (n-1); j++){
loop2++;
for (int k = j+1; k<= n; k++){
loop3++;
}
}
}
printf("%d %d %d\n", loop1, loop2, loop3);
For n = 1000, this prints "998 498501 166167000". To get from 998 to 498501 we multiply by 499.5, which is (n - 1)/2. To get from 498501 to 166167000, we multiply by 333.3333, which is n/3. And 998 is obviously (n - 2). Put it together and you get (n - 2) * (n - 1)/2 * n/3.
If you simplify it, you get this:
(n - 2) * (n - 1)/2 * n/3
(n - 2) * (n/2 - 1/2) * n/3
(n - 2) * (n/2 * n/3 - 1/2 * n/3)
(n - 2) * ((n^2)/6 - n/6)
(n^2)/6 * (n - 2) - n/6 * (n - 2)
n * (n^2)/6 - 2 * (n^2)/6 + n * -n/6 - 2 * -n/6
(n^3)/6 - (n^2)/3 - (n^2)/6 + n/3
(n^3)/6 - (n^2)/2 + n/3
But since we do remove constants and lower-order terms, that simplifies to O(n^3).