In reading a correction for an exercice, I stumbled on a strange equality.
Suppose $x \in [0, \pi]$, let $f_n(x)= \cos^n(x)\sin(x)$, then the derivative is equal to:
$$ \cos^{n+1}(x) - n\sin^2(x)\cos^{n-1}(x)=\cos^{n-1}(x)\left[(n+1)\cos^2(x) -n\right]$$
Could someone explain to me, how is the right part of the equation found?