I'm trying to find how many solutions are there to pick summands for a fixed sum.
How many ways can I choose integers $i,j$, and $k$ such that $0 \le i,j,k < n$ so that their sum is fixed integer $S\in \mathbb{N_0}$: $$i + j + k = S$$
For example, if $S = 2$ then possibilities for $(i,j,k)$ are $\{(2,0,0),(0,2,0),(0,0,2),(1,1,0),(1,0,1),(0,1,1)\}$.
I can't seem to find a simple solution for this.
This problem can be solved by thinking of it in a different way. The number of ways to add three numbers so that the sum is a fixed integer S, is the same as the number of ways you can draw two lines between S dots. For example, if S=5, you could do the following:
||----
|-|----
|--|---
(...)
--|--|--
(...)
-----||
These represent the calculations
0 + 0 + 5 = 5
0 + 1 + 4 = 5
0 + 2 + 3 = 5
etc.
So, in how many ways can you draw two lines between five dots? There are six places, and you must take two of them (repetitions included). The formula for counting combinations (n choose k) with repetitions is
$\binom{n + k - 1}{k}$
In your case $n = S +1 $ and $k=2$, which gives the answer
$\frac{1}{2} (S+1)(S+1)$.
However, if there is an upper limit for the summands, $n< S$, then it becomes more complicated ...