Solution (source code)

= Solution

Put $\alpha=a+x$, $\beta=b+m-x$, and $S=\alpha+\beta=m+a+b$. Integrate the future <binomial distribution> against the current <Beta distribution> <posterior density>:
$$
p(y\mid x)=\binom ny\frac{\mathrm B(\alpha+y,\beta+n-y)}{\mathrm B(\alpha,\beta)},\qquad y=0,\ldots,n.
$$
This is the <beta-binomial distribution>. For positive integer $a,b$, the <gamma function> values reduce to factorials, giving
$$
p(y\mid x)=\frac{n!}{y!(n-y)!}
\frac{(\alpha+y-1)!(\beta+n-y-1)!(S-1)!}
{(\alpha-1)!(\beta-1)!(S+n-1)!}.
$$
Using $(S-1)!=(S-1)(S-2)!$ and $(S+n-1)!=(S+n-1)(S+n-2)!$ rewrites this as
$$
\boxed{p(y\mid x)=\frac{S-1}{S+n-1}
\frac{\binom{\alpha+y-1}{y}\binom{\beta+n-y-1}{n-y}}
{\binom{S+n-2}{n}}.}
$$
Substitution of $\alpha,\beta,S$ gives exactly the two required factors. The probability is zero outside $0\leq y\leq n$.