[Math] Combinations with repetitions allowed, order matters, n less than k

combinations

if you are a Londoner you are familiar with the situation: When you rent a bike a machine will produce a $5$-number code made up of $\{1,2,3\}$. My friend said "oh, I had this number before", but I said it is very unlikely as there are plenty of combinations; when he asked how many, I got stuck.

So here is the difficulty: $k=5$ (number of combinations) is smaller than $n=3$. Repetition IS allowed as it can be a code of $11111$ or $12312$. The order matters as well, so the code $11112$ is not $21111$.

Any ideas how many combinations there is? Thanks!

Best Answer

3 way to pick the first number, 3 ways to pick the second number and so on which equates to $$3^5 =243$$ After only 18 visits, the chances are more likely than not, that you will get a number you have had before.