How many combinations for a 5 digit code using 3 numbers. Can anyone please help here?
I have inherited a strange looking safe with only numbers 1 2 and 3.
The code to open it is 5 digits and the code uses all three numbers at least once.
Is there some formula I can apply to list all the combinations?
Thanks
Let $U$ be the set of all possible combinations with those three digits, $A$ the set of combinations that doesn't use $1$, combinations in $B$  doesn't use $2$, and in $C$ are the ones that don't use $3$.
You're trying to find the number of elements of $U/(A\cup B\cup C)$ where / is difference of sets. It's easy to discover the size of $U$, it is $3^5$. If we discover the size of $A\cup B\cup C$ then we're done.
We first observe that $\# (A\cup B\cup C) = \# A + \# B + \# C - \# (A \cap B) - \# (A \cap C) - \# (B \cap C) + \# (A \cap B \cap C)$, where $\#$ is the size of the set. Then we see that $\# A = \# B = \# C = 2^5$, and $\# (A \cap B) = \# (A \cap C) = \# (B \cap C) = 1$, the last thing is that $\# (A \cap B \cap C) = 0$ as there is no sequence that does not use any number. We conclude that there are $3^5 -3\times 2^5 + 3 = 150$ combinations.
Its easy see we can have repetition its just choosing 1 from 3 digits everytime now we want $5$ digits . Now for every digit we have single choices . So its $3.3.3.3.3=243$ Thats all.