Two integers a and b are
congruent modulo m if and only if a - b is a multiple of m, in which case we write
a≡b modm
.
Thus,
15≡33
mod9
, because
15 - 33 = - 18 is a multiple of 9.
Given integers a and m, the
mod function is given by
a
modm = b if and only if
a≡b
modm
and
0≤b≤m - 1; hence,
a
modm is the smallest nonnegative residue of a modulo m.
The underlying computer algebra system does not understand the congruence
notation
a≡bmodm
, but it does understand
the function notation
a
modm. This section shows how to translate
problems in algebra and number theory into language that Scientific
Notebook can handle.
Note that
mod is a function of two variables, with the function
written between the two variables. This usage is similar to the common usage
of +, which is also a function of two variables with the function values
expressed as a + b, rather than the usual functional notation + (a, b).
Traditionally the congruence notation
a≡b modm
is written with the
modm enclosed inside parentheses
since the
modm clarifies the expression a≡b. In this
context, the expression
b
modm
never appears
without the preceding a≡. On the other hand, the
mod
function is usually written in the form
a
modm without
parentheses.
To evaluate the mod function
Evaluate
23mod14 = 9
If a is positive, you can also find the smallest nonnegative residue of a
modulo m by applying Expand to the quotient
.
Expand
= 1
![]()
Since
1 = 1 +
, multiplication of
= 1 +
by 14 shows that
23
mod14 = 9.
In terms of the floorDM2-4.tex#Floor function
x
, the mod function is given by
a
modm = a -
m .
Evaluate
23 -14 = 9