# Counting the sum of the digits

The problem is,

Let $S$ be the set of five-digit numbers formed by the digits $1, 2, 3, 4$ and $5$, using each digit exactly once such that exactly two odd positions are occupied by odd digits. What is the sum of the digits in the rightmost position of the numbers in S?

I am looking for some approach for solving this problem.

-
Suppose $X_1X_2X_3X_4X_5$ is the 5-digit number. Then if we pick the number at random from $S$, then $X_1X_3X_5$ is uniformly distributed in $132, 134, 352, 354, 512, 514$ and all their permutations (e.g.: $132, 123, 213, 231, 312, 321$, and so on). Then, $E[X_1+X_3+X_5] = \frac{1}{6}(6+8+10+12+8+10) = 9$. Finally, note that the distributions of $X_1$, $X_3$, and $X_5$ are identical; so $E[X_5]=3$. Hence, the required answer is $3|S|$. – Srivatsan Aug 13 '11 at 15:52

A more probabilistic version of the idea used below, indeed essentially a full solution, was given in a comment by @Srivatsan Narayanan.

Conveniently, the odd digits have mean $3$, and so do the even digits.
So we only need to count the number of allowed permutations, and multiply by $3$. It is somewhat easier, or at least safer, to count the complement.

There are $(3!)(2)$, that is, $12$ permutations with all the odd digits in odd positions.

Next we count the permutations with exactly one odd digit in an odd position. That digit can be chosen in $3$ ways. For each choice, its position can be chosen in $3$ ways. Once we have done that, the remaining odd digits can be placed in $2$ ways, and then the even digits can be placed in $2$ ways, for a total of $(3)(3)(2)(2)$, that is, $36$.

So there are $48$ forbidden permutations, leaving $5!-48=72$ allowed permutations.

The required total is therefore $(3)(72)$, which is $216$.

-

If the last digit is even,

2 odd numbers out of 3 can be arranged in 3P2=3! ways,the two even numbers can be arranged in 2! ways

There sum = $$(3! * 2) * (2+4) = 72$$

If the last digit is odd, i.e either 1,3,5

an odd number can only occupy an odd position, so 2C1 = 2 Either one of the two odd digits of the 5 digit number can be selected in 2C1 = 2 Now, the other remaining odd number will have only 2 places left.

The even numbers can be arranged in $$2!$$ ways.

So $$(2 * 2 * 2 * 2) * (1 + 3 + 5) = 144$$

Total sum of right most digits =$$72 + 144 = 216$$

-