I need to compute the following (this is not a homework or etc. just a personal curiosity). How many $7$-digit numbers can be generated with numbers in $S=\{1,2,3,4\}$ such that all of the numbers in $S$ are used at least once?
2026-05-04 16:51:41.1777913501
On
How many $7$-digit numbers can be generated with numbers in $S=\{1,2,3,4\}$ such that all of the numbers in $S$ are used at least once?
74 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
There are 2 best solutions below
0
On
How many $7$-digit numbers can be generated with numbers in $S=\{1,2,3,4\}$ such that all of the numbers in $S$ are used at least once?
By the Inclusion–exclusion principle: $$\underbrace{4^7}_{\text{All numbers that can be formed by }1,2,3,4}-\underbrace{\left[{4\choose 1}3^7-{4\choose 2}2^7+{4\choose 3}1^7\right]}_{\text{Numbers not having at least one of }1,2,3,4}=8400$$
By a brute-force counting algorithm, I obtained a total of $8400$ 7-digit numbers that can be generated with the digits in $S={1,2,3,4}$ such that all of the digits are used at least once.
A possible combinatory solution for this problem is as follows. Once the four digits from $1$ to $4$ have been placed in some positions within our number, there remain three other places $A_1,A_2,A_3$ that can be filled with any digits. We have to consider different cases for this triple.
$$4\binom 743!=840$$
$$4\binom 42 \binom 73 \binom 42=5040$$
$$4 \binom 72 \binom 52 \binom 32=2520$$
Collecting all the results we get that, as expected on the basis of the brute-force counting, the searched total number is
$$840+5040+2520=8400$$
corresponding to $\approx 51.3\%$ of all $4^7=16384$ possible $7$-digit numbers obtainable with the digits from $1$ to $4$.