10
$\begingroup$

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?

$\endgroup$
4
  • $\begingroup$ Firstly, are you allowing leading zeros eg. 0002? If you aren't, it might help to solve this simpler problem first. $\endgroup$ Jul 13, 2015 at 14:28
  • $\begingroup$ "Finding the total number of number is possible." Warm-up: how many numbers are there? This will help you think clearly about the problem. $\endgroup$ Jul 13, 2015 at 14:29
  • $\begingroup$ 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$? $\endgroup$ Jul 13, 2015 at 14:31
  • $\begingroup$ math.stackexchange.com/questions/4042089/… $\endgroup$
    – V.G
    Feb 27, 2021 at 18:28

2 Answers 2

12
$\begingroup$

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.

$\endgroup$
3
  • 2
    $\begingroup$ It's possible that the 4-digit number should not start with 0. $\endgroup$
    – Calvin Lin
    Aug 30, 2013 at 7:27
  • $\begingroup$ 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? $\endgroup$
    – mnulb
    Aug 25, 2018 at 4:27
  • $\begingroup$ @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. $\endgroup$ Dec 15, 2018 at 4:36
2
$\begingroup$
Total[FromDigits /@ Select[Flatten[Permutations /@ 
 Subsets[{0, 2, 3, 5, 8}, {4}], 1], First[#] =!= 0 &]]

(* Out: 467964 *)

I'm due for some down-votes.

$\endgroup$
3
  • $\begingroup$ 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?) $\endgroup$ Sep 2, 2013 at 16:10
  • $\begingroup$ @DouglasS.Stones Thanks - the computation Mathematica. I guess I could have even mentioned that. $\endgroup$ Sep 2, 2013 at 18:52
  • $\begingroup$ 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 ! $\endgroup$
    – user133384
    Mar 5, 2014 at 22:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .