Answer
$r^2-3r+8$
Work Step by Step
Given \begin{equation}
\left(r^3+2 r^2-7 r+40\right) \div(r+5).
\end{equation} Use long division. $$
\begin{array}{r}
r^2-3r+8\phantom{)} \\
r+5{\overline{\smash{\big)}\,r^3+2 r^2-7 r+40\phantom{)}}}\\
\underline{-~\phantom{(}(r^3+5r^2)\phantom{-b)}}\\
0-3r^2-7r\phantom{)}\\
\underline{-~\phantom{()}(-3r^2-15r)}\\
8r+40\phantom{)}\\
\underline{-~\phantom{()}(8r+40)}\\
0\phantom{)}
\end{array}
$$ The solution is \begin{equation}
\frac{r^3+2 r^2-7 r+40}{r+5}=r^2-3r+8.
\end{equation}