Calculate possible combinations with maximum and minimum length

1.2k Views Asked by At

For example, I got $5$ possible characters which can be used for the combination $a, b, c, d, e$. The minimum length of a combination is $2$ characters (e.g. $ab$, $ba$), the maximum length is $5$ (e.g. $abcde$, $abcdd$, $dabca$). I already figured out the following way of calculating possibilities.

$$(5^5) + (5^4) + (5^3) + (5^2)$$

But this formula is different for every different lengths. Also, it will get very long if the maximum length is higher. Is there a more simple formula for calculating it?

1

There are 1 best solutions below

7
On BEST ANSWER

How about making a sum about that? For example, in your case, if you've got 5 possible characters and the maximum length is n, it would be $$5^2+...+5^n=\sum_{k=2}^{n}5^k = \frac{5^2(5^{n-1}-1)}{5-1}$$