Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The two entities may appear identical when printed, but they are different objects:

  • k.mod(n) computes the remainder of division and is equivalent to k % n;
  • mod(k,n) creates an object representing the residue class of k modulo n, that is, $k + n\mathbb Z$.

Take a look:

sage: ZZ(10).mod(3)
1
sage: type( ZZ(10).mod(3) )
<class 'sage.rings.integer.Integer'>

sage: r = mod(10,3)
1
sage: type( r )
<class 'sage.rings.finite_rings.integer_mod.IntegerMod_int'>
sage: r.modulus()
3
sage: r.lift()
1

The two entities may appear identical when printed, but they are different objects:

  • k.mod(n) computes the remainder of division and is equivalent to k % n;
  • mod(k,n) creates an object representing the residue class of k modulo n, that is, $k + n\mathbb Z$.

Take a look:

sage: ZZ(10).mod(3)
1
sage: type( ZZ(10).mod(3) )
<class 'sage.rings.integer.Integer'>

sage: r = mod(10,3)
mod(10,3); print(r)
1
sage: type( r )
<class 'sage.rings.finite_rings.integer_mod.IntegerMod_int'>
sage: r.modulus()
3
sage: r.lift()
1

The two entities may appear identical when printed, but they are different objects:

  • k.mod(n) computes the (integer) remainder of division and is equivalent to k % n;
  • mod(k,n) creates an object representing the residue class of k modulo n, that is, $k + n\mathbb Z$.

Take a look:

sage: ZZ(10).mod(3)
1
sage: type( ZZ(10).mod(3) )
<class 'sage.rings.integer.Integer'>

sage: r = mod(10,3); print(r)
1
sage: type( r )
<class 'sage.rings.finite_rings.integer_mod.IntegerMod_int'>
sage: r.modulus()
3
sage: r.lift()
1