First, my English is not that good so please don't laugh. I need to find a recurrence relation for : The number of words with the length of n that could be composed from the letters A,B,C,D, so the words won't include the combinations "AB","BA","AD" or "BC".
My thinking was to look at the beginning of a word. if it starts with C or D then the continuation has A(n-1) combinations (= A with index n-1). So for the beginning of B or D i get a total of 2*A(n-1). But if the word starts with A, there could be only C or A after this letter. if it's C we continue regularly and say the continuation has A(n-2) combinations. But if there is an A after the A, we have the same situation repeats and repeats until the last letter. so we get for this : A(n-2)+A(n-3)+...+A1
If the word starts with B we get the same combinations as it starts with A so again : A(n-2)+A(n-3)+...+A1
Summing everything gives me the series : An = 2*[A(n-2)+A(n-3)+...+A1] + 2*[A(n-1)] with a1 = 4 , a2 = 12
BUT I wrote a software to bruteforce calculating this thing and realized that the solution is actually the same but adding A1. like this : An = 2*[A(n-2)+A(n-3)+...+A1] + 2*[A(n-1)] + A1 with a1 = 4 , a2 = 12
The series actually starts like this : 4, 12 36, 108, ...
Can someone please tell me where is my mistake and why I don't have this A1 in my solution ? Thanks a lot.
The additional number you need to add at the end of $2A_{n-1}+2A_{n-2}+\cdots+2A_2+2A_1$ is $4$ for the patterns not captured by your recursions, namely "AAA...AAA", "AAA...AAC", "BBB...BBB", "BBB...BBD". Coincidentally this is the same as $A_1$.
There is a much simpler recurrence: $A_n = 3 A_{n-1}$, which can easily be solved as $A_n = 4\times 3^{n-1}$.
Any $n$-letter word can be made up of an $n-1$-letter word followed by a particular letter. But for A at the end you cannot have "...BA"; for B at the end you cannot have "...AB"; for C you cannot have "...BC"; for D you cannot have "...AD". So the particular letter at the end can follow three possible letters at the end of the $n-1$-letter word (but not the fourth). And there is one $1$-letter word of each type. So there are $3^{n-1}$ $n$-letter words ending with each particular letter.