Home

Modulo

Modulo refers to the operation of finding the remainder after division of one number by another. In the standard mathematical convention, for integers a and n with n > 0, a mod n is the unique remainder r such that a = qn + r for some integer q and 0 ≤ r < n. The value of a mod n is called the residue of a modulo n.

In algebra, modulo n is closely linked to the concept of congruence. Two integers a and b

Modulo arithmetic is closed under addition, subtraction, and multiplication. That is, (a + b) mod n = ((a

Common uses include solving problems in number theory, cryptography (such as RSA and elliptic-curve systems), calendar

are
congruent
modulo
n,
written
a
≡
b
(mod
n),
if
n
divides
their
difference
a
−
b.
The
residue
class
of
a
modulo
n
consists
of
all
integers
that
are
congruent
to
a
modulo
n,
and
a
mod
n
is
a
canonical
representative
of
that
class.
mod
n)
+
(b
mod
n))
mod
n,
and
similarly
for
subtraction
and
multiplication.
Division
is
not
always
defined
in
modular
arithmetic;
inverses
exist
only
for
elements
coprime
to
n,
leading
to
the
concept
of
modular
inverses
and
the
multiplicative
group
of
units
modulo
n.
The
set
of
integers
modulo
n
forms
a
finite
ring,
and
when
n
is
prime,
it
forms
a
field
with
respect
to
addition
and
multiplication.
calculations,
hashing,
and
algorithms
that
rely
on
cyclic
properties
and
modular
residue
reduction.
The
terms
modulo,
modulus,
and
remainder
are
related
but
can
be
used
in
slightly
different
senses:
modulo
often
denotes
the
equivalence
relation,
while
remainder
refers
to
the
numerical
residue
from
division.
In
programming,
the
exact
behavior
of
a
mod
n
may
vary
by
language,
especially
for
negative
inputs.