hello...

I'm having a bit of problem with one simple task

First sorry if I put this thread in wrong place

I know how to calculate number of combinations (without repetition)

$\displaystyle \frac {n!}{k!(n-k)!}$

and that's ok

but now I have big problem

I have to calculate number of combinations with repetitions

so i tried like this

when i have 2 variables A and B with second expansion i have :

$\displaystyle AA, AB, BA, BB$

so it's four combinations

for third expansion i have :

$\displaystyle AAA, AAB, ABA, BAA, BBB, BBA, BAB, ABB$

so there is 8 combinations .... and at first i think formula should be $\displaystyle n^k $ or in my case now $\displaystyle 2^n$ meaning $\displaystyle 2^2 = 4 and 2^3 = 8$ but as I get to problem with 4 variables and need to do third expansion by that formula I need 64 combinations... I wrote all of them and I got 40... now I'm confused very much because in next task I have problem with 10 variables and third expansion ... and there is no way that i can wrote them all to find pattern ....

can anyone please help me with this

I also find some formulas for similar things but none of them can be any use to me in this problem