TITLE: How to Calculate Different Variations Without Repetition
QUESTION [2 upvotes]: How do I calculate the amount of different probable values for X in the following scenario.
It can be between 1 and 9 digits (no zero). No digits can repeat inside X.
Invalid:
943288 (repeated 8), 3229 (repeated 2), 
11 (repeated 1), 128809 (zero present)
Valid:
928516, 123, 15

REPLY [5 votes]: Edit: Immediately below is a quick answer to the numerical problem. That is followed by a more general discussion. 
We ask how many $k$-digit numbers there are. The digits we use can be chosen in $\binom{9}{k}$ ways. For each such choice, the $k$ digits can be arranged in $k!$ ways. So the total is 
$$\sum_{k=1}^9 \binom{9}{k}k!.$$
For calculation, use 
$$9+(9\cdot 8)+(9\cdot 8\cdot 7)+\cdots+(9\cdot 8\cdots 2)+(9\cdot 8\cdots 1).$$
By using the "memory" function of the calculator, we can find the answer ($986409$) with not many key presses.  For a much nicer way, see below! 
Remark: First we change the problem slightly by including the empty word. (If we don't like the empty word, subtract $1$ at the end. The mathematics likes the empty word.) And instead of $9$ symbols we use $n$.  
The number of $k$-letter words with no repeated letter is $\binom{n}{k}k!$. Note that $\binom{n}{k}k!=\frac{n!}{(n-k)!}$. Add up from $k=0$ to $k=n$. We get
$n!\left(\frac{1}{n!}+\frac{1}{(n-1)!}+\frac{1}{1!}+\frac{1}{0!}\right)$.
Reverse the order. We get
$$n!\left(1+\frac{1}{1!}+\frac{1}{2!}+\cdots +\frac{1}{n!}\right).$$
We recognize the first $n+1$ terms in the usual series for $e$.  
Add in the "missing" $n!\left(\frac{1}{(n+1)!}+\frac{1}{(n+2)!}+\cdots\right)$. 
These add up to less than the sum of the geometric series $\frac{1}{n+1}+\frac{1}{(n+1)^2}+\frac{1}{(n+1)^3}+\cdots$, which is less than $1$.
So the total number of words, including the empty word, is
$$\left\lfloor n!e\right\rfloor,$$
where $\lfloor x\rfloor$ is the "floor" function. 
In the case $n=9$, $\lfloor n! e\rfloor\approx 986410.11$, so the number of non-empty words is $986409$.
{"set_name": "stack_exchange", "score": 2, "question_id": 180334}