10

Find the sum of all 4-digit numbers formed by using digits 0, 2, 3, 5 and 8.

Finding the total number of number is possible, but how can the sum be found?

Chirayu
  • 101
  • Firstly, are you allowing leading zeros eg. 0002? If you aren't, it might help to solve this simpler problem first. – Colonel Panic Jul 13 '15 at 14:28
  • "Finding the total number of number is possible." Warm-up: how many numbers are there? This will help you think clearly about the problem. – Colonel Panic Jul 13 '15 at 14:29
  • Hint: Let $f(n)$ be the sum of all n-digit numbers formed using digits 0, 2, 3, 5 and 8. Can you find a recurrence relation for $f$? – Colonel Panic Jul 13 '15 at 14:31
  • https://math.stackexchange.com/questions/4042089/find-the-sum-of-all-5-digit-numbers-formed-using-0-1-2-3-4 – V.G Feb 27 '21 at 18:28

2 Answers2

12

If you fix 8 as the last digit, you see that there are $4 \cdot 3 \cdot 2$ ways to complete the number. Thus, 8 appears 24 times as the last digit. By the same logic, if we enumerate all possible numbers using these 5 digits, each number appears 24 times in each of the 4 positions. That is, the digit 8 contributes $(24 \cdot 8 + 240 \cdot 8 + 2400 \cdot 8 + 24000 \cdot 8)$. In total, we have $$(0 + 2 + 3 + 5 + 8)(24 + 240 + 2400 + 24000) = 479952$$ as our total sum.

Update: In case 4-digit numbers cannot start with 0, then we have overcounted. Now we have to subtract the amount by which we overcounted, which is found by answering: "What is the sum of all 3-digit numbers formed by using digits 2,3,5, and 8?" Now if 8 appears as the last digit, then there are 6 ways to complete the number, so 8 contributes $(6\cdot 8 + 60 \cdot 8 + 600 \cdot 8)$. In total, we have $$(2 + 3 + 5 + 8)(6 + 60 + 600) = 11988.$$ Subtracting this from the above gives us 467964.

  • 2
    It's possible that the 4-digit number should not start with 0. – Calvin Lin Aug 30 '13 at 07:27
  • I've one doubt as $8\cdot 24$ counts sum when $8$ is in unit place (eg. $2305\boxed{8}$), then $5\cdot 240$ counts sum when $5$ in tens place (eg. $230\boxed{5}8$), is there no over count? – mnulb Aug 25 '18 at 04:27
  • @mnulb: no, there is no overcount until you do not allow numbers to start with $0$. Another way to see it is that there are $5!$ numbers formed from the five digits. One fifth of them have each digit in a given place, so there are $4!=24$ with each digit in the place. Simultaneously there are $4!$ with each digit in another place. This answer is correct. – Ross Millikan Dec 15 '18 at 04:36
2
Total[FromDigits /@ Select[Flatten[Permutations /@ 
 Subsets[{0, 2, 3, 5, 8}, {4}], 1], First[#] =!= 0 &]]

(* Out: 467964 *)

I'm due for some down-votes.

Mark McClure
  • 30,510
  • I know how you feel. But it is useful to know how to solve problems computationally too, even if it is just to check human-written solutions. (By the way, what language is this?) – Douglas S. Stones Sep 02 '13 at 16:10
  • @DouglasS.Stones Thanks - the computation Mathematica. I guess I could have even mentioned that. – Mark McClure Sep 02 '13 at 18:52
  • And if I would like to compute the sum for a number with 2000 digits that not use the digits 2,0,1 and 4, how can I modify your matematica code to do it ? Thank you ! –  Mar 05 '14 at 22:07