Dividing two polynomials using long division algorithm