Following my previous problem (which was solved) Simplest way to count distinct combinations
(Reading this topic is not mandatory).
Consider I have these letters: A, B, C, D, E.
n is the number of letters, so in this case, n = 5.
I want to get all letter combinations, with lengths from 1 to 5 (the number of letters). From A, AA, ABC, ... to EEEEE. This leads to a total of 3905 possible combinations:
- 1^n = 5
- 2^n = 25
- 3^n = 125
- 4^n = 625
- 5^n = 3125
5 + 25 + 125 + 625 + 3125 = 3905.
Now what if I want to count only combinations that can not have the same letter more than once? I know the result is 325 (when I un-duplicate by hand) but I don't succeed in finding the formula that leads to it.
Thank you, Ben