TITLE: Number of $5$-digit numbers which are divisible by $11$ and whose digits add up to $43$
QUESTION [9 upvotes]: Problem Statement:-
Consider the collection of all $5$-digit numbers such that the sum of digits of each number is $43$. A number is selected at random from the collection. Find the probability that the number is divisible by $11$.

My Solution:-
Let the five-digit numbers be represented by $x_1x_2x_3x_4x_5$.
As the digits of these numbers should add up to $43$, we have 
$$x_1+x_2+x_3+x_4+x_5=43\tag{where $1\le x_i\le9$, $x_i\in\mathbb{N}$}$$
So, the number of such numbers is equal to the coefficient of $x^{43}$ in $\left(\dfrac{1-x^{10}}{1-x}\right)^5=15$
As this is a listable amount of numbers so lets just list them
$$99997\\
99979\\
99799\\
97999\\
79999\\
99988\\
99889\\
98899\\
88999\\
99898\\
98989\\
89899\\
98998\\
89989\\
89998$$
Its easy to spot the numbers divisible by 11 which are $97999,\; 99979,\; 98989$
So, the required probability comes out to be $\dfrac{3}{15}=\dfrac{1}{5}$

The number of numbers in this list turned out to be small hence just listing them turned out to be good enough for finding the numbers divisible by $11$, but what if the sum of the digits of the number turns out to be such that the number of numbers satisfying the condition turns out to be too big. In that case, how am I supposed to find the number of numbers which are divisible by $11$ without the help of a computer but just with pen and paper.

REPLY [2 votes]: what if the sum of the digits of the number turns out to be such that the number of numbers satisfying the condition turns out to be too big. In that case, how am I supposed to find the number of numbers which are divisible by $11$ without the help of a computer but just with pen and paper.

Let us consider the collection of all $5$-digit numbers such that the sum of digits of each number is $S$. 
We know that
$$\text{$\overline{x_1x_2x_3x_4x_5}$ is divisible by $11\iff x_1-x_2+x_3-x_4+x_5=-11,0,11,22$}$$
since $-17=1-9+0-9+0\le x_1-x_2+x_3-x_4+x_5\le 9-0+9-0+9=27$.

If $S$ is odd, then we want to find the number of $(x_1,x_2,x_3,x_4,x_5)$ where $0\le x_i\le 9\in\mathbb Z$ with $x_1\not=0$ such that
$$\begin{cases}
x_1+x_2+x_3+x_4+x_5=S \\
x_1-x_2+x_3-x_4+x_5=-11\end{cases}\quad\text{or}\quad \begin{cases}
x_1+x_2+x_3+x_4+x_5=S \\
x_1-x_2+x_3-x_4+x_5=11\end{cases},$$
i.e.
$$\begin{cases}x_1+x_3+x_5=\frac{S-11}{2}\\ x_2+x_4=\frac{S+11}{2}\end{cases}\quad\text{or}\quad \begin{cases}x_1+x_3+x_5=\frac{S+11}{2}\\ x_2+x_4=\frac{S-11}{2}\end{cases}$$So, using Newton's generalized binomial theorem, we have that the number we want is given by $$\begin{align}&\left([x^{(S-11)/2}] \left(\frac{x-x^{10}}{1-x}\right)\left(\frac{1-x^{10}}{1-x}\right)^2\right)\times\left([x^{(S+11)/2}]\left(\frac{1-x^{10}}{1-x}\right)^2\right)\\\\&\qquad +\left([x^{(S+11)/2}] \left(\frac{x-x^{10}}{1-x}\right)\left(\frac{1-x^{10}}{1-x}\right)^2\right)\times\left([x^{(S-11)/2}]\left(\frac{1-x^{10}}{1-x}\right)^2\right)\\\\&=\left([x^{(S-11)/2}](x-x^{10})(1-x^{10})^2(1-x)^{-3}\right)\times \left([x^{(S+11)/2}](1-x^{10})^2(1-x)^{-2}\right)\\\\&\qquad +\left([x^{(S+11)/2}](x-x^{10})(1-x^{10})^2(1-x)^{-3}\right)\times \left([x^{(S-11)/2}](1-x^{10})^2(1-x)^{-2}\right)\\\\&=\left([x^{(S-11)/2}](x-x^{10}-2x^{11}+2x^{20}+x^{21}-x^{30})\sum_{j=0}^{\infty}\binom{j+2}{2}x^j\right)\\\\&\qquad\qquad\qquad\times \left([x^{(S+11)/2}](1-2x^{10}+x^{20})\sum_{j=0}^{\infty}(j+1)x^j\right)\\\\&\qquad +\left([x^{(S+11)/2}](x-x^{10}-2x^{11}+2x^{20}+x^{21}-x^{30})\sum_{j=0}^{\infty}\binom{j+2}{2}x^j\right)\\\\&\qquad\qquad\qquad\times \left([x^{(S-11)/2}](1-2x^{10}+x^{20})\sum_{j=0}^{\infty}(j+1)x^j\right)\end{align}$$

So, if $S=43$, then the number we want is $$\begin{align}&\left(\binom{17}{2}-\binom 82-2\binom 72\right)\times (28-2\times 18+8)\\\\&\qquad +\left(\binom{28}{2}-\binom{19}{2}-2\binom{18}{2}+2\binom 92+\binom 82\right)\times (17-2\times 7)=3\end{align}$$

If $S$ is even, then we want to find the number of $(x_1,x_2,x_3,x_4,x_5)$ where $0\le x_i\le 9\in\mathbb Z$ with $x_1\not=0$ such that
$$\begin{cases}
x_1+x_2+x_3+x_4+x_5=S \\
x_1-x_2+x_3-x_4+x_5=0\end{cases}\quad\text{or}\quad \begin{cases}
x_1+x_2+x_3+x_4+x_5=S \\
x_1-x_2+x_3-x_4+x_5=22\end{cases},$$
i.e.
$$\begin{cases}x_1+x_3+x_5=\frac{S}{2}\\ x_2+x_4=\frac{S}{2}\end{cases}\quad\text{or}\quad \begin{cases}x_1+x_3+x_5=\frac{S+22}{2}\\ x_2+x_4=\frac{S-22}{2}\end{cases}$$So, similarly as the case where $S$ is odd, the number we want is given by 
$$\begin{align}&\left([x^{S/2}](x-x^{10}-2x^{11}+2x^{20}+x^{21}-x^{30})\sum_{j=0}^{\infty}\binom{j+2}{2}x^j\right)\\\\&\qquad\qquad\qquad\times \left([x^{S/2}](1-2x^{10}+x^{20})\sum_{j=0}^{\infty}(j+1)x^j\right)\\\\&\qquad +\left([x^{(S+22)/2}](x-x^{10}-2x^{11}+2x^{20}+x^{21}-x^{30})\sum_{j=0}^{\infty}\binom{j+2}{2}x^j\right)\\\\&\qquad\qquad\qquad\times \left([x^{(S-22)/2}](1-2x^{10}+x^{20})\sum_{j=0}^{\infty}(j+1)x^j\right)\end{align}$$ So, if $S=36$, then the number we want is $$\begin{align}&\left(\binom{19}{2}-\binom{10}{2}-2\binom 92\right)\times(19-2\times 9)\\\\&\qquad +\left(\binom{30}{2}-\binom{21}{2}-2\binom{20}{2}+2\binom{11}{2}+\binom{10}{2}\right)\times 8=54\end{align}$$