2
$\begingroup$

I think it is rather my lack of correct vocabulary, that I failed to find answer to this question.
I have a variation, eg. passwords, that can have any (and repeated) or none of character in the list. So, for 4 letter password consisting of alpha lowercase, I'll have $26^4$ passwords (at least, I think so. If otherwise, please let me know).
So now, how do I get variants of all passwords from 1 to 4 letters, if I want avoid doing $26^1+26^2+26^3+26^4$?
And, use of sum is NOT what I'm looking for.

$\endgroup$

2 Answers 2

2
$\begingroup$

What you're looking for is the geometric series $$\sum_{i=1}^{n} a^i = a^1 + \cdots + a^n = \frac{a^{n+1}-a}{a-1} $$ In your case with $a=26$ you get for general $n$ the expression $26 (26^n-1)/25$.

$\endgroup$
2
  • $\begingroup$ Thank you for idea with geomethric series - I wouldn't figure that relation out I think... $\endgroup$ Feb 26, 2013 at 19:17
  • $\begingroup$ You're welcome. $\endgroup$ Feb 26, 2013 at 19:28
1
$\begingroup$

The number of words of length between $n$ and $m$ inclusive over an alphabet of $k$ letters is $$\frac{k^{m+1}-k^n}{k-1} $$ In your case $$ \frac{26^5-26^1}{25}=475254.$$

$\endgroup$
1
  • $\begingroup$ I like your m-n range, I think this is what I was looking for. $\endgroup$ Feb 26, 2013 at 17:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .