# How do I work out the number of combinations of a set of items?

If I have a set of 2 characters (1, 2) its quite simple to work out the number of combinations of those 2 characters given the following rules:

1. Each combination must be 2 characters
2. The order of the combination does matter i.e. 12 is not the same as 21
3. A character can be used more than once e.g. 11

The answer to the above would be:
11,12,21,22 = 4 combinations

Note: the formula below cant be used because it does not take into account rule #2 or rule #3

$$\frac{n!}{(n-r)!(r)!}$$

Now, what if the set of available characters increased to 4 (1, 2, 3, 4) and the same rules applied

11,12,13,14,21,22,23,24,31,32,33,34,41,42,43,44 = 16 combinations

I am trying to determine a formula to work out the number of combinations given:

1. The number of available characters (4 in my example above)
2. The length of each combination (2 in my example above)

I need to use the formula to work determine how many combinations of 6 characters there are from a set of 36 available characters.

Any assistance would be most appreciated. I am feeling dumb.

• Look at it as each place in the string having a choice of $n$ characters where each character can repeat. So if the length of the string is $k$, you will have $k^n$ distinct strings. Commented Feb 11, 2021 at 4:54
• @MathLover the answer from Stacker below suggests the formula should be $n^k$ - would you be able to answer in defence? Commented Feb 11, 2021 at 8:23
• No I explained correctly but mistyped in the end :) each place has $n$ choices so it is $n \times n \times ....n = n^k$. Commented Feb 11, 2021 at 8:28

Slots 1-6:
_  _  _  _  _  _
36 36 36 36 36 36

{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9}
some examples:
a9ehur
fh8209
fehiof
38924t
39u99r


36 choices for the first character, 36 choices for the second, ..., 36 choices for the 6th.

36^6=2176782336


2 billion.