What is probability of choose already choosen when we choose n values from set limited to m (n <= m)? I study math many years ago (I am engineer) and not remember how exactly calculate probability for such problem. I choose n values from m set and want calculate probability that all will be unique, has $1$ repeat or less, $2$ repeats or less or $k$ repeats or less.
I have set value $0 .. m$ and I do some choices from this set $n \geq 1$.
Number of choices is less or equal to set size $n \leq m$.
After every choice I return selected value from $0 .. m$ to set.
Maybe it is simple problem but I forget some theory or it is hidden deep in memory and I can not solve it easily.
Examples:

*

*if set is $m = 2$ and choice $n = 2$ probability to not choose same value is $\frac{1}{2}.$

*if set is $m = 3$ and choice $n = 2$ probability to not choose same value is  $\frac{6}{9}$ because $3*3$ permutations and $3$ combos in $2$ orders.

*if set is $m = 3$ and choices $n = 3$ $->$ $p = \frac{6}{27}$ ($3*3*3$ permutations and $3*2$ combos)

How to generalize it with probability equation?
 A: To calculate the probability of no repeats, observe
Total ordered sequences = $m\times m\times \dots\times m = m^n $
Number of sequences with each element distinct = $\binom{m}{n} \times n!=\frac{m!}{(m-n)!} $
The probability is thus $$ \frac{m!}{m^n(m-n)!} $$
A: if n equals 1 you can draw any of the m numbers in the set. So you have
$$\frac{m}{m}$$
if n equals 2 the first draw is as above and in the second draw you can draw one of m-1 numbers in the set. So you have
$$\frac{m}{m}\times\frac{m-1}{m}$$
if n equals 3 the first two draws is as above and in the third draw you can draw one of m-2 numbers in the set. So you have
$$\frac{m}{m}\times\frac{m-1}{m}\times\frac{m-2}{m}$$
and so on.
In general
$$\prod_{i=0}^{n-1}{\frac{m-i}{m}}$$
or
$$\frac{1}{m^n}\prod_{i=0}^{n-1}{{m-i}}$$
The product will give
$$m\times(m-1)\times(m-2)\times\dots\times(m-n+1)$$
or
$$(m\times(m-1)\times(m-2)\times\dots\times(m-n+1))\times\frac{(m-n)!}{(m-n)!}$$
or
$$\frac{m!}{(m-n)!}$$
Putting it all together we get the probabilty of not drawing two indentical numbers to be:
$$\frac{m!}{m^n(m-n)!}$$
