# The total number of seven digit numbers,the sum of whose digits is even are? [closed]

The total number of seven digit numbers,the sum of whose digits is even are?

-

## closed as off-topic by Jonas Meyer, hardmath, Aaron Maroja, TMM, quidMar 22 at 19:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – Jonas Meyer, TMM, quid
If this question can be reworded to fit the rules in the help center, please edit the question.

I am confused with how to think about the summation of digit is even...here we are considering the whole digit as a even number ...but the quest is asking about No of seven digit number whose sum of digits are Even –  prem shekhar Apr 22 '11 at 13:41
@user9325 I tild that thing to kevin just to puzzle him...that he is right but the way he think about the question is not the right logic......i have given my explanations just below..although i aalso explained that where i am stucked........ –  prem shekhar Apr 22 '11 at 13:47
Seven digit no means seven digit integer number that has the digits whose sum is even lik....1234561=22(even).....i wanted to know how many number are lik that...i think i am clear now –  prem shekhar Apr 22 '11 at 13:49
Are you considering $000$ $000$ $2$ to be a seven digit number? –  JavaMan Apr 22 '11 at 19:27

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.

-

Call a number whose digit sum is even good. We need to take account of the fact that for example $037$ is (usually) not considered to be a $3$-digit number.

Look first at $2$-digit numbers. Such a number can start with any of $4$ even digits, and any of $5$ odd digits. An even start can be completed to a good $2$-digit number in $5$ ways (append any of the $5$ even digits). An odd start can be completed to a good number in $5$ ways. Thus there are $(4)(5)+(5)(5)=45$ good $2$-digit numbers. But there are $90$ $2$-digit numbers, so half are good and half are bad.

Now look at $3$-digit numbers. A good $2$-digit numbers can be completed to a good $3$-digit number in $5$ ways. A bad $2$-digit number can also be completed to a good $3$-digit number in $5$ ways, for a total of $450$ good $3$-digit numbers.

Similarly, there are $4500$ good $4$-digit numbers, and so on.

-
Given your earlier answer to the exact same question this seems a bit of a clumsy approach. –  quid May 16 at 17:13
Yes, I am going downhill. –  André Nicolas May 16 at 17:26

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.

-
please read the comments below the questions...i think you will get to know what exactly i am tring to find..thax for your explanation –  prem shekhar Apr 22 '11 at 13:51
That doesn't change my answer. I can add some clarification if you want, but the answer is still correct. –  Raskolnikov Apr 22 '11 at 13:54

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].

-

Hint: how many total $6$ digit numbers are there? Do you permit leading zeros? Then if you are given the first six digits, how many numbers are there that have an even sum of digits?

-

In the $1$ digit case, the sum of digits is the number, so there are $5-1=4$ (excluding $0$) such numbers.

In the $2$ digit case, either both digits must be even or both must be odd. There are $5 \times 5$ where both are even, $25$ where both are odd, but you must subtract the ones with leading zeros - these are $00,02,04,06,08$. So you have $50-5=45$ such numbers.

In the $3$ digit case, all three must be even, or two must be odd and one must be even. There are $5 \times 5 \times 5$ all evens, and $3 \choose 2$ $\times$ $5 \times 5 \times 5$ numbers with one even and 2 odd - think of the forms $112$, $121$, and $211$. Then subtract the ones with leading $0$'s ($000,,002 \ldots 098$), which there are $50$ in total. You get $4 \times 5^3 - 50$ such numbers.

Edit:

In the case of $4$ digits, you need to find all the ways to make the sum even as before. $0 + 0 + 0 + 0$ and $1 + 1 + 1 + 1$ work, as do any combination of two $0$ and two $1$. Thus you have $5^4 \times (1 + 1 + {4 \choose 2})$ such numbers, and as usual, you subtract $5 \times 10^4 = 500$ off to get a total of $4500$.

In the case of $n$ digits, with $n$ odd, you can have all evens ($0$'s), but you cannot have all $1$'s, so start with partioning $n$ choosing $2$ odd's and the rest even's. Then since you cannot have $3$ odds and the rest even, do $4$ odd and the rest even. You get something like:

$${n \choose 0} + {n \choose 2} + \ldots + {n \choose n - 1}$$

Similarly in the even case, you can have all $1$'s, but you still cannot have an odd number of $1$'s and the rest even. So:

$${n \choose 0} + {n \choose 2} + \ldots + {n \choose n}$$

The funny thing is that both of theses sums are equivalent, since if you plug $n=m+1$ into the odd case you get the even case, or in other words, $n \choose 0$ is equal to $n \choose n$.

Since $2^n$ is the sum of the binomial coefficients, $2^{n-1}$ is the sum of the binomial coefficients you are interested in. Thus you always have $2^{n-1} \times 5^n$ such numbers, including the ones with leading $0$'s, but you always need to get rid of the ones with the leading $0$, for which there are always $10^{n-2} \times 5$ of them. $2^{n-1} \times 5^n - 10^{n-2} \times 5 = 10^{n-1} \times 5 - 10^{n-2} \times 5 = 10^{n-2} \times 45$, for $n \gt 1$.

-

Choose the digits one at a time. There are 9 choices for the first digit (all possibilities but 0). Then we can choose all digits but the first and last in $10^{n-2}$ ways. Finally, the last digit can be chosen in $5$ ways, since half the choices will make the sum of the digits even, and the other half will make the sum odd.

So, for example, for $1000$ digit numbers, there are $45*10^{998}$ choices.

-

Suppose the sum of $x$'s digits is even, $x \in {0,\ldots,9999999}$. Then the sum of $x+1$'s digits is odd and vice-versa. Therefore, $$\frac{10^7}{2}$$

-
Don't forget the guys with leading $0$'s! –  tacos_tacos_tacos Jan 29 '13 at 5:48
Not true. For example 19 to 20 –  Carl Jan 29 '13 at 5:48
Even then it should work... because it works for the last digit. –  UnadulteratedImagination Jan 29 '13 at 8:52