mod(k, n) versus k.mod(n)
Where can I read about the difference between mod(k, n) and k.mod(n)? I naively assumed that these were just two different ways of writing the same thing. Is that correct?
add a comment
Where can I read about the difference between mod(k, n) and k.mod(n)? I naively assumed that these were just two different ways of writing the same thing. Is that correct?
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
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2026-02-24 20:30:56 +0100
Seen: 11 times
Last updated: 1 hour ago
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.