# Number of integral solutions to an equation subject to both upper and lower bounds

Find the number of positive integer solutions to $a+b+c+d+e+f= 20$ subject to $1\leq a,b,c,d,e,f\leq 4$.

When there is only the lower bound, i.e $1\leq a,b,c,d,e,f$, we can substitute $g= a-1$, $h= b-1$, $i= c-1$, $j= d-1$, $k= e-1$, $l= f-1$ and then use the ball and sticks method to find the number of solutions to the equation $g+h+i+j+k+l= 14$. Similarly when there is only the upper bound, i.e. $a,b,c,d,e,f\leq 4$, we can substitute $g= 4-a$, $h= 4-b$, $i= 4-c$, $j= 4-d$, $k= 4-e$, $l= 4-f$ and then use the ball and sticks method to find the number of non negative integral solutions to the equation $g+h+i+j+k+l= 4$. But what will be the approach when there is both upper bound and lower bound? When there was only the upper bound we knew that $g,h,i,j,k,l$ are always non negative, but they can be any non negative integers, because $a,b,c,d,e,f$ can be negative which implies $a,b,c,d,e,f$ can also be greater than $4$. Now when two bounds are introduced, we still know that $g,h,i,j,k,l$ are non negative but they cannot be greater than $4$. So we cannot use the ball and sticks method that way. My question is how do we approach in such cases?

You could use the generating function method: the number of solutions with sum $n$ is the coefficient of $x^n$ in $(x + x^2 + x^3 + x^4)^6$.
• I did use the lower bound ($1$). That's why it's $x+\ldots$ instead of $1+x+\ldots$. – Robert Israel May 31 '13 at 15:07