Ask Your Question

Revision history [back]

I do not know if this is the best answer but it works

sage: K = Zmod(543)    # the ring Z/nZ
sage: R.<x> = PolynomialRing(K,'x')
sage: f = 3*x^5 + 2*x + 1
sage: g = 2*x + 1
sage: f.quo_rem(g)
(273*x^4 + 135*x^3 + 204*x^2 + 441*x + 52, 492)

The method quo_rem returns the 2-tuple made of the quotient and the remainder of the division.