While I personally never have seen a problem like this, I would solve it as follows.
Find two numbers, that when added give the "b". (-6,+1), but (-3, -2) also works here.
Then use long division with your functions to calculate the remainder of n^2-5n+1/((n-6)(n+1))
Does this answer your question?
Sorry, I was unclear. I know this is true, I found it basically how HallsOfIvy did: guess to replace -5 with 16 and factor as usual. My question was, if I did not know the factorization of the polynomial, how could I find it algorithmically?