[Math] Permutation formula for lock combination

permutations

I know the basic permutation formula for k objects out of an n set. But what is the formula for determining the number of permutations where k is a range (1..m) ?

What are the formula for the following scenarios?

1) a keyless door lock has n distinct buttons, the combination can be any length (1..m), and in any sequence, but each button can only be used once.

2) same as 1, except any step in the sequence (1..m) can be two buttons pushed together, the constraint that a button only pressed once, still holds

Best Answer

Let's do (1) and you can finish (2) yourself.

  1. Pick the buttons for the combination - $\binom{n}{m}$ ways
  2. Arrange them in any of the $m!$ orders.

You get $$\binom{n}{m} m! = \frac{n!}{(n-m)!}$$

UPDATE This takes care of any fixed $m$. To get the result for different $m$, add different possibilities: $$ \sum_{k=1}^m \frac{n!}{(n-k)!} $$

Related Question