The total number of seven digit numbers,the sum of whose digits is even are?
|
|
Whatever the first (leftmost) six digits are, there are exactly $5$ ways to complete them to a $7$-digit number whose digit-sum is even, and $5$ ways to complete them to a $7$-digit number whose digit-sum is odd. So exactly half of the $7$-digit numbers have even digit-sum. |
|||
|
|
|
It's actually the same as the amount of 7 digit even numbers. It's easy to see that the numbers satisfy the following recursion $$a_n=9\cdot(a_{n-1}+a_{n-2}+\ldots+a_1) \text{ and } a_1=5 $$ by just checking what happens for low values of $n$. EDIT: Just to make things clear, when $n=1$ the amount of even 1-digit numbers and the amount of 1-digit numbers with sum even is the same because the numbers are the same, and that means there are $5$ such numbers. Then, take the 2-digit numbers, let's start with those of the form $1\star$. Then, compared to the one digit numbers, those who will have even sum are those with second digit an odd one, but there are still $5$. Then for the numbers of the form $2\star$, the ones with an even last digit will be OK, again $5$ numbers. And so on, in total, we'll get $9\cdot 5$ even sum 2-digit numbers. For 3-digit numbers, we can apply the same reasoning, look at $1\star\star$, then the ones with even sum of digits will be the ones that had odd sums of 1- and 2-digit numbers. There are $5+45$. Apply a similar reasoning to $2\star\star,\ldots,9\star\star$ and you get $9 \cdot (5 + 45) = 450$ such numbers. So, you'll see that my recursion formula is indeed correct. |
|||||||
|
|
Interesting recursion the one in the answer by @Raskolnikov. Let's try our hand at giving a closed from solution. For simplicity, define $b_n = a_{n + 1}$, and define the ordinary generating function: $$ B(z) = \sum_{n \ge 0} b_n z^n $$ The original recursion is now: $$ b_{n + 1} = 9 \sum_{0 \le k \le n} b_k \qquad b_0 = 5 $$ Using properties of ordinary generating functions (see e.g. Wilf's "generatingfunctionology") this gives: $$ \frac{B(z) - 5}{z} = 9 \frac{1}{1 - z} B(z) $$ Your tame computer algebra package (or pencil and paper) gives: $$ B(z) = \frac{1}{2} + \frac{9}{2} \cdot \frac{1}{1 - 10 z} $$ From here one can read the coefficients: $$ b_n = \begin{cases} 5 & n = 0 \\ \frac{9}{2} \cdot 10^n & n \ge 1 \end{cases} $$ But we are interested in $a_n = b_{n - 1}$, which for $n \ge 2$ is $\frac{9}{5} \cdot 10^n$. For the original question, we have $a_6 = 450,000$. [Sorry for the rambling, but this just doesn't fit into a comment]. |
|||
|
|