finding the remainder of a polynomial - Search