Where $x_i \in \mathbb{Z} \geq 2$ and $x_i \neq 5$
So far I tried the following using stars and bars:
Let $(x_i -2) = y_i$
$y_1 + y_2 + y_3 + y_4 = 30-2-2-2$
$y_1 + y_2 + y_3 + y_4 = 22$
${22+4-1\choose 4-1} = 2300$
Can someone verify if my answer is correct and steer me in the direction of how to find the number of solutions with the added condition of $x_i \neq 5$.
Best Answer
We want to find the number of integer solutions of the equation $$x_1 + x_2 + x_3 + x_4 = 30 \tag{1}$$ subject to the restrictions that $x_i \geq 2$, $x_i \neq 5$, for $1 \leq i \leq 4$.
As Severin Schraven pointed out in the comments, we can handle the first condition by defining $x_i = y_i + 2$ for $1 \leq i \leq 4$. Making these substitutions in equation 1 yields \begin{align*} y_1 + 2 + y_2 + 2 + y_3 + 2 + y_4 + 2 & = 30\\ y_1 + y_2 + y_3 + y_4 & = 22 \tag{2} \end{align*} Equation 2 is an equation in the nonnegative integers. Since a particular solution corresponds to the placement of $4 - 1 = 3$ addition signs in a row of $22$ ones, the number of solutions of equation 2 in the nonnegative integers is $$\binom{22 + 4 - 1}{4 - 1} = \binom{25}{3}$$ since we must choose which three of the $25$ positions required for $22$ ones and three addition signs will be filled with addition signs.
From these, we must subtract those solutions of equation 1 in which one or more of the $x_i$'s are equal to $5$ or, equivalently, those solutions of equation 2 in which one or more of the $y_i$'s is equal to $3$. Notice that at most three of the $x_i$'s may equal to $3$ since $4 \cdot 3 = 12 < 22$.
If $y_4 = 3$, then \begin{align*} y_1 + y_2 + y_3 + 3 & = 22\\ y_1 + y_2 + y_3 & = 19 \tag{3} \end{align*} Equation 3 is an equation in the nonnegative integers. Since a particular solution of equation 3 corresponds to the placement of $3 - 1 = 2$ addition signs in a row of $19$ ones, equation 3 has
solutions in the nonnegative integers. By symmetry, there are an equal number of solutions of equation 2 in which $y_1 = 3$ or $y_2 = 3$ or $y_3 = 3$ or $y_4 = 3$. Hence, the number of solutions in which one of the $y_i$'s is equal to $3$ is
However, if we subtract this amount from the total, we will have subtracted too much since we will have subtracted each case in which two $y_i$'s are equal to three twice, once for each way we could have designated one of those $y_i$'s as being the one that is equal to $3$. We only want to subtract such cases once, so we must add them back.
If $y_3 = 3$ and $y_4 = 3$, then \begin{align*} y_1 + y_2 + 3 + 3 & = 22\\ y_1 + y_2 & = 16 \tag{4} \end{align*} Equation 4 is an equation in the nonnegative integers. Since a particular solution of equation 4 corresponds to the placement of $2 - 1 = 1$ addition sign in a row of $16$ ones, equation 4 has
solutions in the nonnegative integers. By symmetry, there are an equal number of solutions of equation 2 for each of the $\binom{4}{2}$ pairs $i, j$ such that $1 \leq i < j \leq 4$ in which $y_i = y_j = 3$. Hence, there are
solutions of equation 2 in which two $y_i$'s are equal to $3$.
However, if we add these to our running total, we will have added too much. This is because we first subtracted those cases in which three $y_i$'s are equal to $3$ three times, once for each way we could designate one of the $y_i$'s as being the one that equals $3$, then subtracted them three times, once for each of the $\binom{3}{2}$ ways we could designate a pair of the $y_i$'s as being the pair $(y_i, y_j)$ with $1 \leq i < j \leq 4$ in which $y_i = y_j = 3$. Hence, we have not subtracted those cases in which three of the $y_i$'s are equal to $3$.
If $y_2 = y_3 = y_4 = 3$, then \begin{align*} y_1 + 3 + 3 + 3 & = 22\\ y_1 & = 13 \tag{5} \end{align*} which is an equation in the nonnegative integers with one solution. By symmetry, there are an equal number of solutions for each of the $\binom{4}{3}$ ways of selecting triples $(i, j, k)$ with $1 \leq i < j < k \leq 4$ in which $y_i = y_j = y_k = 3$. Hence, there are
solutions in which three of the $y_i$'s are equal to $3$.
By the Inclusion-Exclusion Principle, the number of admissible solutions of equation 1 is