Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

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

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

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

share|improve this answer
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
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.