If P(x) is divided by (x-1)(x+2), the remainder will
have the form Ax + B. Because
the remainder must have a lower power than the thing you
are dividing by, which is a quadratic. So the remainder is at most
linear.
In other words, P(x) = (x-1)(x+2)Q(x) +
Ax + B.
where Q(x) is some unknown function which is
two powers lower than P(x). We don't really need
to know anything more about Q(x).
At this point, we can use the info given. Since
P(x) has remainder 5 when divided by (x−1), and
remainder 8 when divided by (x+2), the Remainder Theorem tells us that
P(1) = 5 and P(−2) = 8.
Now we can solve for A and B.