14

How do I find the average of all $6$ digit numbers which consist of only digits $1,2,3,4$ and $5$?

Do I have to list all the possible numbers and then divide the sum by the count? There has to be a more efficient way, right?

Thank you!

Naffi
  • 295
user88999
  • 141

6 Answers6

30

Given any of our numbers $x$ except $333333$, call $666666-x$ the partner of $x$. Note that the partner of the partner of $x$ is $x$. So, apart from $333333$, our numbers come in couples.

The average of any two partners is $333333$, and the solitary number is $333333$, so the average of all the numbers is $333333$.

André Nicolas
  • 507,029
  • Why the exception? Why 333333 can't be 333333's partner? Fits the definition you gave... – mike3996 Aug 05 '13 at 14:32
  • 1
    @progo, that would imply that there are two 3333333's in the summation. But that's not correct. – Winston Ewert Aug 05 '13 at 14:42
  • Well, it doesn't really fit the definition I gave, since the definition said given any of our numbers $x$ except $333333$, $\dots$. I wanted to think of our numbers as made up of a bunch of couples, together with one single person. – André Nicolas Aug 05 '13 at 14:42
  • Heh, that is true enough. I probably approached the definition from the point that it wouldn't affect the outcome to include one extra 333333 in there. – mike3996 Aug 05 '13 at 14:59
  • You are right, it wouldn't if we count the extra $333333$ as an extra person. But that is not quite as obvious as the reasoning I used. Another version is to paint all our numbers blue, and for every number $x$ put in $666666-x$ painted red. Then the reds are the same numbers as the blues, $333333$ no longer needs special treatment. We now have twice as many numbers, but the average has not changed. – André Nicolas Aug 05 '13 at 15:08
  • I agree that it is as important to get both the answer and the reasoning correct. – mike3996 Aug 05 '13 at 16:16
  • That approach only works for sets like $1,2,3,4,5$ consisting of pairs whose average is equal to the total average, and possibly a digit that is the average. A more general solution, which is also easier to arrive it, is simply that each digit is independent from the other digits in the sum of the combinations. The answer is just the average of the digits times $111,111$. That works just as well for, say, $1,3,4,8,9$, where the answer is $555,555$. – Mark Adler Aug 05 '13 at 19:53
  • Yes, I took maximal advantage of the symmetry. The method does not generalize to non-symmetric situations. However, this kind of pairing argument can be very useful in, for example, elementary number theory. – André Nicolas Aug 05 '13 at 20:03
15

It's actually very simple and I'll give you a few hints.

Think about only the ones digit. It can only contain either 1, 2, 3, 4, or 5. Now I want to average only one digit numbers. So what's the average over all one digit numbers that contain only 1, 2, 3, 4, and 5?

Once you answer that question, think about this question. Does anything change if we consider the 10s digit? Or the hundreds? In other words, if we can do it for the ones digit, let's exploit what we already know for all the other digits.

muffle
  • 738
12

Don't want to completely give it away, but there are $5^6$ of these numbers as the first through sixth digits can all take on five different values. I'm sure there's something slicker you could do, but it should be easy to then sum them all up by evaluating the sum $$ \sum_{a=1}^5 \sum_{b=1}^5 \sum_{c=1}^5 \sum_{d=1}^5 \sum_{e=1}^5 \sum_{f=1}^5 (a \cdot 10^5+b \cdot 10^4+ c \cdot 10^3+d \cdot 10^2+ e \cdot 10^1 + f \cdot 10^0) $$ and dividing by the total number of them.

  • -1 for needless complication. – jwg Aug 05 '13 at 15:09
  • +1 I think it is instructive to know that you can go brute force when you don't immediately see a trick and you still get the answer pretty immediately. It's also good to see nested sums as independent choices. The sums aren't complicated in the least and shouldn't be something to be scared of. – ex0du5 Aug 06 '13 at 01:42
1

$$(111111+111112+\cdots+555555)=$$ $$(100000\times 5^5+200000\times 5^5+\cdots+500000\times 5^5)+(10000\times 5^5+20000\times 5^5+\cdots+50000\times 5^5)+\cdots+(1\times 5^5+2\times 5^5+\cdots+5\times 5^5)$$

vadim123
  • 82,796
0

The digit $1$ will contribute $111,111\cdot 5^5$ to the sum of all such $6$ digit numbers. Similarly, the digit $2$ will contribute $222,222\cdot 5^5$ to the sum.

Continuing, we obtain the sum:

$$(111,111+222,222+333,333+444,444+555,555)\cdot 5^5=3\cdot(555,555)\cdot5^5$$

Divide this by the total number of such $6$ digit numbers ($5^6$) to obtain an average of $333,333$.

Jared
  • 31,451
0

The generating function of these numbers is $$f(x) = \prod_{q=0}^5 \left(x^{10^q} + x^{2 \times 10^q}+ \cdots + x^{5 \times 10^q}\right).$$ Hence the number of values is given by $$f(1) = \prod_{q=0}^5 5 = 5^6,$$ (this part is trivial but it confirms that we have the right generating function).

Similarly, the sum of these numbers is given by $$\left.\frac{d}{dx} f(x)\right|_{x=1} \\ = \left.\prod_{q=0}^5 \left(x^{10^q} + x^{2 \times 10^q}+ \cdots + x^{5 \times 10^q}\right) \\ \times \sum_{q=0}^5 \frac{10^q \times x^{10^q-1} + 2\times 10^q \times x^{2 \times 10^q-1}+ \cdots + 5\times 10^q \times x^{5 \times 10^q-1}} {x^{10^q} + x^{2 \times 10^q}+ \cdots + x^{5 \times 10^q}} \right|_{x=1}$$ which is $$5^6 \frac{1}{5} \sum_{q=0}^5 10^q \times(1+2+\cdots+5),$$ so the average is $$\frac{\left.\frac{d}{dx} f(x)\right|_{x=1}}{f(1)} = \frac{1}{5} \times 15 \times \sum_{q=0}^5 10^q = 3\times 111111 = 333333.$$

Marko Riedel
  • 61,317