Consider $n$ labeled balls, $k$ of which are red and $(n-k)$ blue. Given a permutation of these balls, we tick $n-1$ times. For the $i$-th tick, if the $i$-th ball in the permutation is red, then it paints the $(i+1)$-th ball in the permutation blue (if the latter is already blue, then it remains blue).
We secretly mark one of the red balls at the beginning. How many permutations are there in which our marked ball becomes blue by the end of the process?


I want to prove that the answer is


$$
\sum\_{j=0}^{k-2}(-1)^j\frac{n!2^{k-2-j}{{k-1}\choose{j}}(k-1-j)}{n-j}.
$$


To show this, I was trying to use the inclusion-exclusion principle without success. How could we derive this formula?


ps.: There are other (maybe nicer) formulas that would work, but I am particularly interested in the one given above.


**Edit:** Thank you for all the great answers so far! My main question, however, remains open: how to prove that the formula I proposed is correct?



Counting permutations defined by a simple process
Let us put an additional blue ball in position $0$, to the left of the $n$ balls.
The condition on the permutations of the $n$ balls is then that the marked red ball be preceded by an odd number (say $2r-1$) of red balls, which in turn must be preceded by a blue ball. Let us refer to such permutations as good.
Let $p\_{n,k}$ denote the number of good permutations of the $k$ red balls and $n-k$ blue ones.


Let $j$ be the position of the marked red ball in a good permutation. Then $j\ge2r$.


If $j=2r$, then $j$ is even and the only blue ball to the left of the marked red ball is the additional blue ball in position $0$. So, for any given even $j\in[n]:=\{1,\dots,n\}$, the number of good permutations with $2r=j$ is
\begin{equation\*}
 \Big(\prod\_{i=0}^{j-2}(k-1-i)\Big)(n-j)!=\frac{(k-1)!(n-j)!}{(k-j)!}. 
\end{equation\*}
(If $j>k$, then the latter fraction is understood as $0$.)


Similarly counted are the good permutations with $j>2r$, where we must use one of the $n-k$ blue balls to place it immediately to the left of the $2r-1$ red balls preceding the marked red ball.


Thus,
\begin{equation\*}
\begin{aligned}
 p\_{n,k}&=\sum\_{j\in[n]}\Big(
 1(j\text{ is even})\frac{(k-1)!(n-j)!}{(k-j)!} \\ 
 &+\sum\_{1\le r<j/2}(n-k)\frac{(k-1)!(n-2r-1)!}{(k-2r)!}
 \Big) \\ 
&=(k-1)!\sum\_{j\in[k]}
 1(j\text{ is even})\frac{(n-j)!}{(k-j)!} \\ 
 &+(k-1)!(n-k) 
 \sum \_{r=1}^{\lfloor k/2\rfloor } \frac{(n-2 r)!}{(k-2 r)!} \\ 
 &=(k-1)!(n-k+1) 
 \sum\_{r=1}^{\lfloor k/2\rfloor } \frac{(n-2 r)!}{(k-2 r)!}. 
\end{aligned}
\end{equation\*}




---


This very simple expression is easy to analyze. Indeed, consider what is, according to the OP's comment, the case of interest: $n=2k-1$. Then
\begin{equation\*}
 p\_{n,k}=q\_k:=p\_{2k-1,k}=k!\sum\_{r=1}^{\lfloor k/2\rfloor } \frac{(2k-1-2 r)!}{(k-2 r)!}.
\end{equation\*}
The OP wanted to show that
\begin{equation\*}
 P\_k:=\frac{q\_k}{(2k-1)!}
\end{equation\*}
is $\le1/3$ and $P\_k\to1/3$ as $k\to\infty$.


To prove this, write
\begin{equation\*}
 P\_k=\sum\_{r=1}^\infty a\_{k,r}, \tag{1}\label{1}
\end{equation\*}
where
\begin{equation\*}
 a\_{k,r}:=\frac{k!}{(2k-1)!} \frac{(2k-1-2 r)!}{(k-2 r)!};
\end{equation\*}
the latter fraction is understood as $0$ if $2r>k$. We can also write
\begin{equation\*}
 a\_{k,r}=\prod\_{i=0}^{2r-1}\frac{k-i}{2k-1-i}
 =\frac{k}{2k-1}\prod\_{i=1}^{2r-1}\frac{k-i}{2k-1-i}
 \le \frac{k}{2k-1}\frac1{2^{2r-1}}. 
\end{equation\*}
It also follows that $a\_{k,r}\to\frac1{2^{2r}}$ as $k\to\infty$, for each natural $r$. So, by \eqref{1} and dominated convergence,
\begin{equation\*}
 P\_k\to\sum\_{r=1}^\infty \frac1{2^{2r}}=\frac13, \tag{2}\label{2}
\end{equation\*}
as was desired.


Next, it is easy to see that, for each natural $r\ge2$, $a\_{k,r}$ is increasing in natural $k\ge2r$. A little complication here is that $a\_{k,1}$ is decreasing in $k$. However, it is rather easy to see that $\sum\_{r=1}^3 a\_{k,r}$ is increasing in natural $k\ge5$. So, by \eqref{1}, $P\_k$ is increasing in natural $k\ge5$.
So, by \eqref{2}, $P\_k<1/3$ for $k\ge5$. It also easy to see that $P\_k<1/3$ for $k\in\{1,3,4\}$ and $P\_2=1/3$.
Thus, $P\_2=1/3$ and $P\_k<1/3$ for $k\in\{1,3,4,5,6,\dots\}$, as was also desired.


