# Sum of Numbers with distinct digiits?

1. Apr 6, 2011

### FryerMath

I need to find the sum of all 4536 numbers with distinct digits from 1000 to 10000 (so 4 digit numbers). Now, I developed a primary method for a solution but its too time consuming! anybody have any clever ideas?

Last edited: Apr 6, 2011
2. Apr 6, 2011

### gb7nash

Are you allowed to make a program that calculates it?

3. Apr 6, 2011

4. Apr 6, 2011

### ramsey2879

I think the purpose is for you to work this out on your own. But I will get you on the right path.
Suppose you write the numbers down twice only in two columns. In the first column write then in the order 1000, 1001, 1002 ... 9999. In the second column you assume the numbers are written in reversed order. If I understand you there should be 9000 numbers in each column, not the 4536 total you mentioned in your post. Now suppose you add the pair in each row and put in column 3: 1000 + 9999 = 10999; 1001 + 9998 = 10999; 1002 + 9997 = 10999; ... 9999+1000 = 10999.

How many 10999's will ther be in column 3 when you are done.
What is the sum of these 10999's represent ( in respect to the sums of the numbers in columns 1 and 2)?
Edit OK I think I see why there are only 4536 total numbers. Each of the four digits must be distinct!! That calls for a more specific solution.
With each digit from 1 to 9 in the thousands position you have 9*7*6 total ways to write the remaining digits. So the total of the sum of the digits in the thousands position will be T(9) * 9*8*7 or 45*9*8*7. You use a slightly different method to total the digits from 1 to 9 in the 100's, 10's and 1's positions. Zeros dont count in the sum but they figure in the determination of how many of each digit there would be in the 1000's, 100's or 10's or 1's.

Last edited: Apr 6, 2011
5. Apr 6, 2011

### FryerMath

No, sorry. The digits of the numbers have to be distinct
doing what you explained would be a lot easier though
just use n(n+1)/2 from 1-10,000 and then again from 1-1000 and subtract the second from the first

6. Apr 7, 2011

### Xitami

9*C(9,3)*3!=4536

4536/9=504
digit 1000
0 * 0
1 * 504 = 504
2 * 504 = 1008
...
9 * 504 = 4536
sum = 22680

why 504 & 448? <--- ???
digit 100
0 * 504 = 0
1 * 448 = 448
...
9 * 448 = 4032
sum = 20160

digit 10
...
digit 1
...

20160*3 + 22680 = 83160

7. Apr 7, 2011

### FryerMath

Sorry, No. There are 4536 numbers with each valuing above 1000. So, the SUM must be at least 4536,000 (BUT it is more!).

8. Apr 7, 2011

### Petek

I think that Xitami has the right idea, but left out some details. Let's consider

$$abcd = 10^3 a + 10^2 b + 10 c + d$$

where a, b, c, d are distinct integers between 0 and 9, and $a \neq 0$. The problem is to sum all numbers abcd that meet these conditions. First, we sum the contributions from the leading digit. The leading digit can take any of the values 1, 2, ..., 9. For any choice of the leading digits there are 9x8x7 = 504 choices for the next three digits. Therefore, the sum of the leading digits is

$$1 \cdot 10^3 \cdot 504 + 2 \cdot 10^3 \cdot 504 + \cdots + 9 \cdot 10^3 \cdot 504 = 45 \cdot 504 \cdot 10^3$$

Next we consider the contribution of the second digit to the sum. The second digit b can take any of the 10 values 0, 1, ..., 9. If b = 0, then there are again 9x8x7 choices for the remaining digits. For each choice of b = 1, 2, ..., 9, there are 8 possibilities for a (since a can't equal 0), 8 choices for c (since c can equal 0) and 7 choices for d, a total of 8x8x7 = 448. If b = 0, it contributes nothing to the sum, so we may disregard it. Therefore, the total contribution of the second digit to the sum is

$$1 \cdot 10^2 \cdot 448 + 2 \cdot 10^2 \cdot 448 + \cdots + 9 \cdot 10^2 \cdot 448 = 45 \cdot 448 \cdot 10^2$$

The contributions of the third and fourth digits to the sum are handled similarly. I'll let you work it out from here. Post your final answer and I'll tell you if it agrees with mine.

9. Apr 7, 2011

### ramsey2879

I think that both myself and Xitami left out some detail for FryerMath to fill in. I just gave the sum of the digits in the thousands position 45*9*8*7. I see FryerMath knew to multiply that figure by 1000. I was hoping he would see how to arrive at the figure 45*8*8*7 for the sum of the digits in the 100's position himself. As you say a similar analysis such as you gave should apply to the 10's and 1's digit sums.
PS I should have edited out the steps to find the sum of all 4 digit numbers as soon as I saw it irrelevant as it was a distraction from my final message.

Last edited: Apr 7, 2011
10. Apr 10, 2011

### FryerMath

Petek, you were correct! Thank you! I verified the solution with a collegue. I summed the values up to be 24887520

11. Apr 10, 2011

### ramsey2879

You seem to be off by some 30 + thousand.

12. Apr 11, 2011

### Xitami

+30240

13. Apr 11, 2011

### Perfection

My way:

If we allow for leading zeros (the numbers 0123-9876) the solution is quite obviously 4999.5 * 10!/(10-4)! (because every digit at every place is equiprobable)

so if we just subtract off the 3 digit numbers we're good.

We can calculate 3 digit numbers with the same method as above but this includes 2 digit numbers that aren't included in the 4 digit calculation... and so on...

the final calculation is thus:
4999.5 * 10!/(10-4)! - 499.5 * 10!/(10-3)! + 49.5 * 10!/(10-2)! - 4.5 * 10!/(10-1)!

24,842,250

Last edited: Apr 11, 2011
14. Apr 11, 2011

### ramsey2879

I think Petek, Xitami and I each came up with 24,917,760 as the answer. Using your method I would put it at 1111*45*9!/(9-3)! - 111*45*9!/(9-2)! + 11*45*9!/(9-1)! -45 or 24,842,250 which is your answer. I am not sure why your method gives a different answer, but I am certain that 1000*45*9*8*7 + 111*45*8*8*7 which equals 24,917,760 is the correct answer.

Last edited: Apr 11, 2011
15. Apr 11, 2011

### Perfection

Yeah, there's double counting here. For instance 0104 would be subtracted from the total erroneously.

Crud!

16. Apr 12, 2011

### Petek

Yes, I also got 24,917,760.

17. Apr 12, 2011

### ramsey2879

That is the key, once there is a leading zero, there can be no more zeros. So
the answer is 1111*9*8*7*45 - 111*8*7*45 or 24917760