[Math] How many $4$-digit numbers can be formed from the digits $1,2,3,4,5,6,7$ if each digit can only be used once and sum of digits is even

combinationscombinatoricspermutations

How many $4$-digit numbers can be formed from the digits $1,2,3,4,5,6,7$ if each digit can only be used once and sum of digits is even?

$7 \cdot 6 \cdot 5 \cdot 4 = 840$ numbers

Okay, I can solve all $4$-digit numbers, each digit used just once, but how can I meet the condition: sum of digits must be even?

Best Answer

The hints in the comment section provides valuable insights to the problem.

I will write a complete answer just to be sure you understand the hints.

There are $3$ cases whereby the sum of the $4$ digits is even,

(1) All $4$ digits are odd.

(2) All $4$ digits are even.

(3) $2$ digits are odd and $2$ digits are even.

First, note that there are $4$ odd digits and $3$ even digits in the set $\{1,2,3,4,5,6,7\}$.

Let's start with Case (1).

Since each digit can only be chosen once, there is $4$ ways of choosing the first odd digit from $\{1,3,5,7\}$,

followed by $3$ ways of choosing the second odd digit from the remaining $3$ digits,

followed by $2$ ways of choosing the third odd digit from the remaining $2$ digits,

followed by $1$ way of choosing the forth odd digit from the remaining $1$ digit.

So, there are $4\times 3 \times 2\times 1 = 4!$ possibilities for Case (1).

Now on to Case (2),

there are $3$ even digits in $\{1,2,3,4,5,6,7\}$, namely $2,4,6$.

Remember that the $4$ digit number must contain different digits, we cannot use either $2$, $4$ or $6$ more than once to construct the $4$ digit number.

And furthermore, there are only $3$ even digits available, so it is impossible to construct any $4$ digit number with no repetition of a digit.

Hence, there is $0$ possibilities for Case (2).

Finally, let's move on to Case (3), which is slightly more difficult.

We first do an unordered selection of $2$ odd digits from $\{1,3,5,7\}$.

which gives $\binom{4}{2}$ possibilities,

followed by an unordered selection of $2$ even digits from $\{2,4,6\}$.

which gives $\binom{3}{2}$ possibilities.

An example would be choosing the digits $1, 5, 2, 4$.

We can quickly see that a valid $4$ digit number would be $1524$.

Note that other permutations of the $4$ digits also form a valid $4$ digit number,

example, $5124$ and $1542$.

and, there are $4!$ permutations in total.

So, by the product rule, there are $\binom{4}{2} \times \binom{3}{2} \times 4!$ possibilities.

Finally, by sum rule, there are a total $4! + 0 +\binom{4}{2} \times \binom{3}{2} \times 4!$ possibilities for the $3$ mutually exclusive cases.