Arrange distinct objects and ordered roles
Derive factorials and falling products from choices without replacement.
Understand the idea
Arranging n distinct objects fills positions with n, n − 1, ..., 1 choices, producing n!. Filling r ordered roles from n distinct candidates gives P(n, r) = n(n − 1)...(n − r + 1). Changing the order changes the outcome when roles differ.
Trace a small example
Choosing a captain and a deputy from five people gives 5 × 4 = 20. Selecting nobody is one empty outcome, so 0! = 1 and P(n, 0) = 1. A selection with r > n is impossible under the no-reuse rule.
Conditions and cost
Factorials grow rapidly: 20! fits in signed 64-bit, while 21! does not. Bound intermediate values, not only the final answer. Use a falling product when only r ordered choices are needed.
How many ways can 4 distinct books be arranged in a row?
Turn the idea into code
Choose gold, silver, and bronze winners from 6 competitors with no ties.
Give me a hint
The medals are different roles.
Show the explained solution
6 × 5 × 4 = 120. Dividing by 3! would incorrectly make the ranked winners unordered.
Your notes
Mark complete when you can explain it yourself.