# The integer Euclidean remainder: irem remain smod mods mod %

### 5.5.9 The integer Euclidean remainder: irem remain smod mods mod %

The irem command finds the remainder of two integers (see Section 5.5.8).
remain is a synonym for irem.

- irem takes two arguments:
  a and b, integers.
- irem(a,b) returns the remainder r of a divided by b.

#### Examples.

- Input:
  irem(148,5)
  Output:

  3

- Input:
  irem(factorial(148),factorial(45)+2 )
  Output:

  111615339728229933018338917803008301992120942047239639312

- Input:
  irem(25+12*i,5+7*i)
  Output:

  −4+i

  Here r=a−b*q=−4+i and |−4+i|2=17<|5+7*i|2/2=74/2=37

The smod command finds the symmetric remainder of two (ordinary) integers.
mods is a synonym for smod.

- smod takes two arguments:
  a and b, integers.
- smod(a,b) returns the symmetric remainder s of the Euclidean division of a and b; namely, the value s with a=b*q+s and −b/2<s ≤ b/2.

#### Example.

Input:

smod(148,5)

Output:

−2

The mod operator is an infixed operator which takes an integer to a modular integer.
% is a synonym for mod.

- mod has two operands: a and b, ordinary integers.
- a mod b returns r % b in ℤ/bℤ, where r is the remainder of the Euclidean division of the arguments a and b.

#### Example.

Input:

148 mod 5

or:

148 % 5

Output:

⎛ ⎝ | −2 | ⎞ ⎠ | %5

Note that the result -2 % 5 is not an integer (-2) but an element of Z/5Z (see Section 5.34 for the possible operations in Z/5Z).