TITLE: When the polynomial $mx^3-nx^2+5x-1$ is divided by $x+2$ the remainder is $-39$?
QUESTION [6 upvotes]: When the polynomial $mx^3-nx^2+5x-1$ is divided by $x+2$ the remainder is $-39$. When the polynomial is divided by $x-1$ the remainder is $3$. Find the values of $m$ and $n$. 
My attempt?: I feel I did something incorrect
$$-8m -n -10 - 1 = -39\\
m - n + 5 - 1 = 3$$
Subtract the first equation from the second one.
$$-9m -15 = -42\\
9m = 27\\
m = 3$$
Plug m into one of the equations 
$$3 - n + 5 - 1 = 3\\
n = 4$$

REPLY [3 votes]: Lemma: Let $p(x)$ be a polynomial (over $\mathbb{R}[x]$ say) and let $a\in\mathbb{R}$. Then, the remainder of division of $p(x)$ by $x-a$ is $p(a)$.
Proof. Let $q(x)$ and $r(x)$ be the quotient and remainder of the division of $p(x)$ by $x-a$. Then, the degree of $r(x)$ must be $0$, i.e., $r(x)=r$ is a constant, and
$$p(x)=q(x)(x-a)+r.$$
Therefore, if we evaluate the displayed expression at $a$, we obtain
$$p(a)=q(a)(a-a)+r=0+r=r.$$
Hence, $r=p(a)$ as claimed.
Example. Let $p(x)=mx^3-nx^2+5x-1$, and suppose that the remainder when divided by $x+2$ is $-39$, and the remainder when divided by $x-1$ is $3$. By our Lemma, this implies that $p(-2)=-39$ and $p(1)=3$. Hence,
$$-8m-4n-11=-39 \ \text{ and } \ m-n+4=3,$$
or, equivalently,
$$2m+n=4\ \text{ and } \ m-n=-1.$$
Hence, $n=m+1$, and $4=2m+m+1$ so $3m=3$. Thus, $m=1$, and $n=2$.