Solution (source code)

= Solution

For fixed $x$ add $K\Pi(t)$ to $p(t)-f(t)$ so the resulting <function> also vanishes at $t=x$. Repeated Rolle gives a point $\xi$ where its $(n+1)$st <derivative> vanishes, yielding the formula.