Distribute n identical items (stars) into k distinct boxes by placing k−1 dividers (bars). Drag a bar to change the distribution; the count C(n+k−1, k−1) stays fixed for given n, k.
| Operation | Time | Notes |
|---|---|---|
| C(n+k−1, k−1) multiplicative loop | O(min(k, n)) | exact, divide-as-you-go |
| C(m, r) mod p, precomputed factorials | O(1) | after O(N) precompute |
| Positive count C(n−1, k−1) | O(min(k, n)) | needs n ≥ k |
| Upper-bound count (uniform cap, PIE) | O(k) | ≤ k+1 signed terms |
| Upper-bound count (varied caps, subset PIE) | O(2ᵏ) | prune forced > n |
| Brute-force enumerate all solutions | O(C(n+k−1, k−1)) | testing only |