f(x)=f1(x)(x+1)-5=f2(x)(x-2)+7 where f, f1 and f2 are polynomials in x. For convenience I'll use these terms so that (x) is understood. f1=(f+5)/(x+1), f2=(f-7)/(x-2). Therefore f1f2=(f+5)(f-7)/(x^2-x-2)=(f^2-2f-35)/(x^2-x-2). Because f1 and f2 are polynomials and therefore not fractions or containing fractions, the right-hand side must also be a polynomial, and f^2-2f=f(f-2) must divide exactly by the denominator. This has to work for all values of x. The constant -35 is fixed and independent of x, so it can only be the remainder. Therefore the remainder is -35.