Tuesday, 31 March 2015

PnC : Sum of numbers formed by digits provided


This article deals with various possibilities that exist when it comes to questions of finding the sum of all the numbers that can be formed by using some digits provided in the question
with some constraints. Let's discuss today how and why these problems are dealt the way they are.
Case 1 : When digits are not repeated and doesn't include zero

Let's take a small example to understand the generic concept. Say, we have, digits 1,2 and 3 and we form all possible three digit numbers from it using each digit only once. We'll get 123,132,213,231,312,321 as the possible 6(=3!) numbers.
But, what about their sum?
Look at it this way : Choose a digit out of these and keep it fixed at unit's place and arrange the other.Following the same for all provided digits we'll get the sum as :
123
213
132
312
231
321
So what eventually happens is we get each of the n digits at each of the places(unit,ten's,etc) for (n - 1)!
times since we fixed one of the digits while forming the arrangement. Assigning face value of each place(1 to unit's, 10 to ten's , 100 to hundredth's , etc) we get the final result as :

(Sum of the digits provided) * (10^(n - 1) + 10^(n - 2) + ... + 1) * (n - 1)!
for sum of all n-digit numbers formed by the given n digits.


So here we get : (1 + 2 + 3) * (100
+ 10 + 1) * (3 - 1)! = 6 * 111 * 2 =  1332.


Case 2 : When digits can be repeated and zero is not included.
Going by the same concept here, the only difference here is that when you arrange the digits after fixing one of the digits you still can take the selected digit again. Hence instead of (n - 1)*(n - 2) *... = (n - 1)! options, you will have n*n*n...(n - 1) times = n^(n - 1) permutations.


Hence the formula becomes :
(Sum of the digits provided) * (10^(n - 1) + 10^(n - 2) + ... + 1) * n^(n - 1)


Case 3 : When digits include 0 as well.
We know that if we are considering n-digit numbers, zero cannot be placed at the MSB position(or in simple terms the leftmost digit of number). So what we do for this type of a case is we calculate the sum of numbers as we would for Case 1 or Case 2 assuming 0 as part of the digit set and find sum for n-digit numbers(including n).

But subtract from this the sum of all (n - 1) digit numbers that can be formed using other digits using Case 1 or Case 2 again. This is done as a 5 digit number 01234 is same as a 4 digit number 1234.
Hence calculating sum of all 5 digit numbers from 0,1,2,3,4 and subtracting from it sum of 4 digit numbers using 1,2,3,4 will remove the unnecessary sum of 5 digit numbers that start from 0 at MSB.

Hence, say digits : 0,2,3,4 (no repetition)
Then,
Sum of all 4 digit numbers = (0 + 2 + 3 + 4)*(1111)*3! - (2 + 3 + 4)*111*2!


Case 4 : When digit set itself contains repeated digits.
If you
have understood the Case 1 and Case 2 by logic you would understand that change would occur only in the permutation part of n! by dividing for repetition that occurs to compensate for repeated permutations.
It's same like : Arrange 1,2,3,4 = 4! but if it's arrange 1,2,3,3, it will be 4!/2! and for that matter to eliminate any confusion arranging 1,2,2,3,3 would be 5!/2!2!. Same goes for this case.

example : Find sum of all 5 digit numbers formed from 1,3,5,5,7 with no digit repeated other than repetition mentioned.

Solution : (1 + 3 + 5 + 5 + 7)*(11111)*[(5 - 1)!/2!] = Answer.


You should be able to understand a question with repetition allowed and a repeated digit set wouldn't make sense.

Hope this article resolves your conflicts with this domain of problems in PnC that appear in MBA examinations. Rate, Like and Share if you like the content. Leave comments here in case of any query.



Cheers!
AS

6 comments:

  1. What if the set of digits is {0, 1,3,5,5,7} and the sum of 4-digit numbers is asked?

    ReplyDelete
    Replies
    1. Small example as illustration:
      2 digit numbers
      0,1,1,2
      10
      20
      11
      12
      21

      0 and 1 : 1*11*1! - 1*1*0! = 10
      0 and 2 : 2*11*1! - 2*1*0! = 20
      1,2 : (1 + 2)*11*1! = 33
      1,1 : (1 + 1)*11*1!/2! = 11

      Delete
  2. Break it down to separate disjoint cases and apply the standard cases explained above individually or in combination as applicable.
    Case 1 : Zero selected and {1,3,7}
    Case 2 : Zero selected and {5,5,x} where x = 1/3/7
    Case 3 : Zero not selected and {1,3,5,7} selected
    Case 4 : Zero not selected and {5,5,x,y} selected where x,y belong to distinct elements of set {1,3,7}
    Each case being a sub-question in itself.
    Hope it helps!

    ReplyDelete
  3. Wow! Impressive collection of formuale,
    Thank you Mr. Anubhav Sehgal : )

    ReplyDelete