# Compute sum of variations - ammount of password variants

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.

-

## 2 Answers

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.$$

-
I like your m-n range, I think this is what I was looking for. – Tomáš Zato Feb 26 '13 at 17:51

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$.

-
Thank you for idea with geomethric series - I wouldn't figure that relation out I think... – Tomáš Zato Feb 26 '13 at 19:17
You're welcome. – Elmar Zander Feb 26 '13 at 19:28