irem (or remain) returns the integer remainder r from
the Euclidean division of two integers a and b given as arguments
(a=b*q+r avec 0≤ r< b).
For Gaussian integers, we choose q so that b*q is as near by a as
possible and it can be proved that r may be choosen so that
|r|2 ≤ |b|2/2.
Input :
Output :
irem works with long integers or with Gaussian integers.
Example :
Output :
Another example
Output :
Here a−b*q=−4+i and |−4+i|2=17<|5+7*i|2/2=74/2=37
smod or mods is a prefixed
function and has two integers a and b as arguments.
smod or mods returns the
symetric remainder s of the Euclidean division of the
arguments a and b (a=b*q+s with −b/2<s ≤ b/2).
Input :
Output :
mod (or %) is an infixed function
and has two integers a and b
as arguments.
mod (or %) returns r% b of Z/bZ where r is the remainder of
the Euclidean division of the arguments a and b.
Input :
or
Output :
Note that the answer 3 % 5 is not an integer (3) but an element of Z/5Z (see 2.31 to have the possible operations in Z/5Z).