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$
  • $\begingroup$ Firstly, are you allowing leading zeros eg. 0002? If you aren't, it might help to solve this simpler problem first. $\endgroup$ – Colonel Panic Jul 13 '15 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$ – Colonel Panic Jul 13 '15 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$ – Colonel Panic Jul 13 '15 at 14:31
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$
  • 2
    $\begingroup$ It's possible that the 4-digit number should not start with 0. $\endgroup$ – Calvin Lin Aug 30 '13 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 '18 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$ – Ross Millikan Dec 15 '18 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$
  • $\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$ – Douglas S. Stones Sep 2 '13 at 16:10
  • $\begingroup$ @DouglasS.Stones Thanks - the computation Mathematica. I guess I could have even mentioned that. $\endgroup$ – Mark McClure Sep 2 '13 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 '14 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.