Number of solutions for an inequation $7 \le x_1 + x_2 + x_3 + x_4 \le 12$

How many solutions are there for the inequation: $7 \le x_1 + x_2 + x_3 + x_4 \le 12$?

So I thought about counting solutions for $x_1 + x_2 + x_3 + x_4\le 12$ then, count solutions for $x_1 + x_2 + x_3 + x_4\le 7$ and then subtract.

I read somewhere that $x_1 + x_2 + x_3 + x_4 \le 12$ can be written as $x_1 + x_2 + x_3 + x_4 + x_5 = 12$ so number of solutions is ${12 + 4 \choose 4} = 1820$

Number of solutions for $x_1 + x_2 + x_3 + x_4 + x_5 = 7$ would be ${7 + 4 \choose 4} = 330$

Final answer: $1820 - 330 = 1490$

Is this correct?

• Are the variables supposed to be nonnegative integers? – N. F. Taussig Apr 14 '18 at 21:26

You want to subtract the solutions to $x_1+x_2+x_3+x_4 \le 6$, so you get $${\small{\binom{12+5-1}{5-1}}}-{\small{\binom{6+5-1}{5-1}}} = {\small{\binom{16}{4}}}-{\small{\binom{10}{4}}} =1820-210 =1610$$ If the variables were specified as positive integers, you would get $${\small{\binom{13-1}{5-1}}}-{\small{\binom{7-1}{5-1}}} = {\small{\binom{12}{4}}}-{\small{\binom{6}{4}}} =495-15 =480$$