number of permutations in which $k$ numbers come after each other

377 Views Asked by At

I have $n$ numbers and I want to calculate the number of permutations in which $k$ certain numbers appear after each other (e.g. numbers $1$ to $10$ ($n = 10$), and let's say I want the permutations in which $6$ comes after $3$, and $3$ comes after $9$ ($k = 3$); they do not have to be subsequent like $..**9\;3\;6**..$ but any permutation like $..2**\;9**\;4**\;3**\;8\;7**\;6**..$ is also acceptable as still $6$ comes after $3$ and $3$ comes after $9$). I went ahead and solved it for different situations and came up with the following sort of a formula:

$$-1+\sum\limits_{i=0}^{n-k}(i+1)\cdot(n-k-i+1)!$$

So like for $n = 5$ and $k = 3$ we have $13$ possible permutations for any selected $3$ numbers (like for $1,\;3$ and $4$ to appear after each other among numbers $1$ to $5$) and so on! It seems the formula works fine (I tried it for several combinations) but you know this is a terrible way of calculation (at least to me!) as I had to first calculate the answer for many different situations and then eventually obtain the above-mentioned formula. So I was wondering if there is a better way of calculating this!

1

There are 1 best solutions below

1
On BEST ANSWER

Just ignore all the other numbers and there are $k!$ possible orders of the $k$ numbers, one of which is acceptable. That means $\frac 1{k!}$ of the permutations are acceptable. As there are $n!$ total permutations, the number of acceptable ones is $$\frac {n!}{k!}$$