Permutation formula for lock combination

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

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)!}$$

• I believe you shared the formula for permutations for a fixed sample size n out of a population of m. My question is about a variable sample size (1..m) – MarkE Jun 14 '16 at 22:15
• @MarkE see update – gt6989b Jun 15 '16 at 3:57
• Are you sure that is correct? The answer is undefined when m=n – MarkE Jun 15 '16 at 17:37
• @MarkE $0!=1$... – gt6989b Jun 15 '16 at 17:44
• Doh! Wasn't thinking. – MarkE Jun 15 '16 at 23:00