= Solution
First take $0<p<1$. For $X\sim\operatorname{Bin}(n,p)$, <independence> of the Bernoulli trials gives
$$
\mathbb E(e^{tX})=(1-p+pe^t)^n.
$$
For $x\geq p$ and $t>0$, <Markov inequality> yields
$$
P(X\geq nx)\leq e^{-tnx}(1-p+pe^t)^n.
$$
Differentiate the logarithm of the right-hand side to minimize it. The stationary point satisfies
$$
e^{t_*}=\frac{x(1-p)}{p(1-x)},
$$
which is at least $1$ when $x\geq p$. Substitution gives
$$
\boxed{P(X\geq nx)\leq
\left[\left(\frac px\right)^x\left(\frac{1-p}{1-x}\right)^{1-x}\right]^n.}
$$
When $x=p$, use the limit $t_*\to0$, giving the trivial bound $1$.
For $x\leq p$, take $t<0$. On $\{X\leq nx\}$ we have $e^{tX}\geq e^{tnx}$, so the same <Markov inequality> gives the same expression. Its minimizing $t_*$ is now nonpositive, yielding the stated lower-tail bound. No rounding of $nx$ is needed, because the exponential event inclusion holds for real thresholds. The cases $p=0$ and $p=1$ are deterministic and follow directly, or by the corresponding limits.
Back to article page