I'm trying to find a formula for nested loops that have the structure of:
for (int a = 0; a < n; a++) {
for (int b = a+1; b < n; b++) {
for (int c = b+1; c < n; c++) {
...
}
}
}
This can be imagined as a combination of f-digits (one digit for every for-loop) out of n different values where each following digit has to be at least "1 bigger" than the previous digit.
The correct solution for $n=200$ and $f=3$ would be $1313400$ for example. (I just counted the number of iterations in Java.)
I can't find a formula to calculate it though. I thought I could calculate it with: ${200 \choose 1}*{199 \choose 1}*{198 \choose 1}$ but that returns 7880400
This is just $\binom nf$ .
The key point here is that any, unordered, collection of distinct digits can be ordered increasingly in exactly one way. Thus there is a bijection between the sequences of the form you want and unrestricted, unordered collections. The latter are of course what the binomial symbol counts.
As a sanity check, we note that $\binom {200}3=1313400$ as desired.