Determine the number of all nonnegative integer solutions to $x + y + z = 11$ with $x\leq 3$, $y\leq 4$, and $z \leq 6$.

1.1k Views Asked by At

Determine the number of all nonnegative integer solutions to $x+y+z = 11$ with $x\leq 3$, $y\leq 4$, and $z \leq 6$.

3

There are 3 best solutions below

0
On

The number of solutions is $6$:

\begin{equation} \begin{array} \\ x = 1, & y = 4, & z = 6 \\ \\ x = 2, & y = 3, & z = 6 \\ \\ x = 2, & y = 4, & z = 5 \\ \\ x = 3, & y = 2, & z = 6 \\ \\ x = 3, & y = 3, & z = 5 \\ \\ x = 3, & y = 4, & z = 4 \\ \end{array} \end{equation}

Here is some R code that finds the solutions:

#Matrix for saving results
mat <- matrix(NA,ncol = 1,nrow = 3)
colnames(mat) <- c("x","y","z")

#Loop through all possible values
for (x in c(0,1,2,3)){
  for (y in c(0,1,2,3,4)){
    for (z in c(0,1,2,3,4,5,6)){

        if(x+y+z == 11){

          mat <- cbind(mat,c(x,y,z))


      }
    }
  }
}
0
On

A program in VB to be run in Excel:

Sub Macro1546687()
'
CONT = 1
'
For I = 0 To 3
For J = 0 To 4
For K = 0 To 6
'
Sum = I + J + K
'
If Sum = 11 Then
     Cells(CONT, 1) = I
     Cells(CONT, 2) = J
     Cells(CONT, 3) = K
     CONT = CONT + 1
End If
'
Next K
Next J
Next I
'
End Sub
0
On

$(3-x)+(4-y)+(6-z)=2$

So the number of solutions is $\large{2+3-1\choose3-1}=6$