Enhanced the divmod function to include polynomials

Kindly ignore the earlier pull request by me that was submitted regarding the same issue.