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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

From combinatorics, it's known that over an alphabet of $n$ symbols there are $n^k$ different strings of length $k$, of which $\frac{n!}{(n-k)!}$ (assuming $k \le n$) are those without any repeated symbols.

But how to find how many strings of length $k$ without consecutive symbols repeated?

For example if the alphabet is {A, B, C }, acceptable strings are ABAB and BACA, whereas ABBA or AAAA are not.

share|cite|improve this question
up vote 8 down vote accepted

Hint: You have $n$ choices for the first symbol. After that, you always have $n-1$ choices.

share|cite|improve this answer
...which means there are $n*(n-1)^{(k-1)}$ possible strings of length $k$ without consecutive symbols repeated over an alphabet of $n$ symbols. – Claudio Floreani Dec 4 '11 at 20:21
@Claudio Floreani: Yes, that's right. I wanted to leave you something to do! – André Nicolas Dec 4 '11 at 21:33

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.