I am working on a homework problem and I am given this situation:
Let $A$ be the event that the $r$ numbers we obtain are all different from each other. So, for example, if $n = 3$ and $r = 2$ the sample space is $S = \{(1, 1),(1, 2),(1, 3),(2, 1),(2, 2),(2, 3),(3, 1),(3, 2),(3, 3)\}$ and the event $A$ is $A = \{(1, 2),(1, 3),(2, 1),(2, 3),(3, 1),(3, 2)\}$.
My task is to solve for the general case and put together a formula.
For the random experiment described above, find the probability $P(A)$ for a general $n$ and $r$. [Hint: If $r = 1$, we don't choose any duplicate numbers, so $P(A) = 1$. If $r > n$, then our choice of $r$ numbers must contain some duplicates, so $P(A) = 0$. The interesting case is when $2 \leq r \leq n$.]
I found this relatively simple to do while programming on R, however I do not know where to begin when putting a formula together for the general case. Any explanations would be helpful!
Hint. You'll do better by thinking rather than (brute force) programming.
Can you calculate the size of the sample space? That depends only on $n$. You've already done $n=3$ and found $9$ elements.
Now how many ways can you choose $r$ different elements in order from among $n$? You found $6$ when $n=3$ and $r=2$. Work out a few more cases and find the pattern.