In
modular arithmetic #REDIRECT Modular arithmetic#REDIRECT Modular arithmetic
In mathematics
Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), a ...
, the
integer
An integer (from the Latin
Latin (, or , ) is a classical language belonging to the Italic branch of the Indo-European languages. Latin was originally spoken in the area around Rome, known as Latium. Through the power of the Roman Re ...
s
coprime
In number theory, two integer
An integer (from the Latin wikt:integer#Latin, ''integer'' meaning "whole") is colloquially defined as a number that can be written without a Fraction (mathematics), fractional component. For example, 21, 4, 0, ...
(relatively prime) to ''n'' from the set
of ''n'' non-negative integers form a
group
A group is a number
A number is a mathematical object used to counting, count, measurement, measure, and nominal number, label. The original examples are the natural numbers 1, 2, 3, 4, and so forth. Numbers can be represented in language with ...
under multiplication
modulo ''n'', called the multiplicative group of integers modulo ''n''. Equivalently, the elements of this group can be thought of as the
congruence classes, also known as ''residues'' modulo ''n'', that are coprime to ''n''.
Hence another name is the group of primitive residue classes modulo ''n''.
In the
theory of rings, a branch of
abstract algebra
In algebra, which is a broad division of mathematics, abstract algebra (occasionally called modern algebra) is the study of algebraic structures. Algebraic structures include group (mathematics), groups, ring (mathematics), rings, field (mathema ...
, it is described as the
group of units
In the branch of abstract algebra known as ring theory
In algebra, ring theory is the study of ring (mathematics), rings—algebraic structures in which addition and multiplication are defined and have similar properties to those operations def ...
of the ring of integers modulo ''n''. Here ''units'' refers to elements with a
multiplicative inverse
Image:Hyperbola one over x.svg, thumbnail, 300px, alt=Graph showing the diagrammatic representation of limits approaching infinity, The reciprocal function: . For every ''x'' except 0, ''y'' represents its multiplicative inverse. The graph forms a r ...
, which, in this ring, are exactly those coprime to ''n''.
This
quotient group
A quotient group or factor group is a math
Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geome ...
, usually denoted
, is fundamental in
number theory
Number theory (or arithmetic or higher arithmetic in older usage) is a branch of devoted primarily to the study of the s and . German mathematician (1777–1855) said, "Mathematics is the queen of the sciences—and number theory is the queen ...

. It has found applications in
cryptography
Cryptography, or cryptology (from grc, , translit=kryptós "hidden, secret"; and ''graphein'', "to write", or ''-logia
''-logy'' is a suffix in the English language, used with words originally adapted from Ancient Greek ending in (''- ...

,
integer factorization
In number theory
Number theory (or arithmetic or higher arithmetic in older usage) is a branch of pure mathematics devoted primarily to the study of the integers and arithmetic function, integer-valued functions. German mathematician Carl Frie ...
, and
primality test
A primality test is an algorithm
In and , an algorithm () is a finite sequence of , computer-implementable instructions, typically to solve a class of problems or to perform a computation. Algorithms are always and are used as specification ...
ing. It is an
abelian,
finite
Finite is the opposite of Infinity, infinite. It may refer to:
* Finite number (disambiguation)
* Finite set, a set whose cardinality (number of elements) is some natural number
* Finite verb, a verb form that has a subject, usually being inflected ...
group whose order is given by
Euler's totient function
The first thousand values of . The points on the top line represent when is a prime number, which is
In number theory, Euler's totient function counts the positive integers up to a given integer that are relatively prime to . It is written ...
:
For prime ''n'' the group is
cyclic
Cycle or cyclic may refer to:
Anthropology and social sciences
* Cyclic history, a theory of history
* Cyclical theory, a theory of American political history associated with Arthur Schlesinger, Sr.
* Social cycle, various cycles in social scienc ...

and in general the structure is easy to describe, though even for prime ''n'' no general formula for finding
generators is known.
Group axioms
It is a straightforward exercise to show that, under multiplication, the set of
congruence class
In mathematics
Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It ...
es modulo ''n'' that are coprime to ''n'' satisfy the axioms for an
abelian group
In mathematics
Mathematics (from Greek: ) includes the study of such topics as numbers ( and ), formulas and related structures (), shapes and spaces in which they are contained (), and quantities and their changes ( and ). There is no g ...
.
Indeed, ''a'' is coprime to ''n'' if and only if . Integers in the same congruence class satisfy , hence one is coprime to ''n'' if and only if the other is. Thus the notion of congruence classes modulo ''n'' that are coprime to ''n'' is well-defined.
Since and implies , the set of classes coprime to ''n'' is closed under multiplication.
Integer multiplication respects the congruence classes, that is, and implies .
This implies that the multiplication is associative, commutative, and that the class of 1 is the unique multiplicative identity.
Finally, given ''a'', the
multiplicative inverse
Image:Hyperbola one over x.svg, thumbnail, 300px, alt=Graph showing the diagrammatic representation of limits approaching infinity, The reciprocal function: . For every ''x'' except 0, ''y'' represents its multiplicative inverse. The graph forms a r ...
of ''a'' modulo ''n'' is an integer ''x'' satisfying .
It exists precisely when ''a'' is coprime to ''n'', because in that case and by
Bézout's lemma there are integers ''x'' and ''y'' satisfying . Notice that the equation implies that ''x'' is coprime to ''n'', so the multiplicative inverse belongs to the group.
Notation
The set of (congruence classes of) integers modulo ''n'' with the operations of addition and multiplication is a
ring.
It is denoted
or
(the notation refers to taking the
quotient
In arithmetic
Arithmetic (from the Ancient Greek, Greek wikt:en:ἀριθμός#Ancient Greek, ἀριθμός ''arithmos'', 'number' and wikt:en:τική#Ancient Greek, τική wikt:en:τέχνη#Ancient Greek, έχνη ''tiké échne' ...
of integers modulo the
ideal
Ideal may refer to:
Philosophy
* Ideal (ethics)
An ideal is a principle
A principle is a proposition or value that is a guide for behavior or evaluation. In law
Law is a system
A system is a group of Interaction, interacting ...
or
consisting of the multiples of ''n'').
Outside of number theory the simpler notation
is often used, though it can be confused with the
-adic integers when ''n'' is a prime number.
The multiplicative group of integers modulo ''n'', which is the
group of units
In the branch of abstract algebra known as ring theory
In algebra, ring theory is the study of ring (mathematics), rings—algebraic structures in which addition and multiplication are defined and have similar properties to those operations def ...
in this ring, may be written as (depending on the author)
(for German ''Einheit'', which translates as ''unit''),
, or similar notations. This article uses
The notation
refers to the
cyclic group
In group theory
The popular puzzle Rubik's cube invented in 1974 by Ernő Rubik has been used as an illustration of permutation group">Ernő_Rubik.html" ;"title="Rubik's cube invented in 1974 by Ernő Rubik">Rubik's cube invented in 1974 by Er ...

of order ''n''.
It is
isomorphic
In mathematics
Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). I ...
to the group of integers modulo ''n'' under addition.
Note that
or
may also refer to the group under addition.
For example, the multiplicative group
for a prime ''p'' is cyclic and hence isomorphic to the additive group
, but the isomorphism is not obvious.
Structure
The order of the multiplicative group of integers modulo ''n'' is the number of integers in
coprime to ''n''.
It is given by
Euler's totient function
The first thousand values of . The points on the top line represent when is a prime number, which is
In number theory, Euler's totient function counts the positive integers up to a given integer that are relatively prime to . It is written ...
:
.
For prime ''p'',
.
Cyclic case
The group
is
cyclic
Cycle or cyclic may refer to:
Anthropology and social sciences
* Cyclic history, a theory of history
* Cyclical theory, a theory of American political history associated with Arthur Schlesinger, Sr.
* Social cycle, various cycles in social scienc ...

if and only if ''n'' is 1, 2, 4, ''p''
''k'' or 2''p''
''k'', where ''p'' is an odd prime and . For all other values of ''n'' the group is not cyclic.
This was first proved by
Gauss
Johann Carl Friedrich Gauss (; german: Gauß ; la, Carolus Fridericus Gauss; 30 April 177723 February 1855) was a German mathematician
This is a List of German mathematician
A mathematician is someone who uses an extensive knowledge of m ...

.
This means that for these ''n'':
:
where
By definition, the group is cyclic if and only if it has a
generator ''g'' (a
generating set
In mathematics and physics, the term generator or generating set may refer to any of a number of related concepts. The underlying concept in each case is that of a smaller set (mathematics), set of objects, together with a set of Operation (mathe ...
of size one), that is, the powers
give all possible residues modulo ''n'' coprime to ''n'' (the first
powers
give each exactly once).
A generator of
is called a
primitive root modulo ''n''.
If there is any generator, then there are
of them.
Powers of 2
Modulo 1 any two integers are congruent, i.e., there is only one congruence class,
coprime to 1. Therefore,
is the trivial group with element. Because of its trivial nature, the case of congruences modulo 1 is generally ignored and some authors choose not to include the case of ''n'' = 1 in theorem statements.
Modulo 2 there is only one coprime congruence class,
so
is the
trivial groupIn mathematics
Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It ha ...
.
Modulo 4 there are two coprime congruence classes,
and
so
the cyclic group with two elements.
Modulo 8 there are four coprime congruence classes,
and
The square of each of these is 1, so
the
Klein four-group
In mathematics, the Klein four-group is a Group (mathematics), group with four elements, in which each element is Involution (mathematics), self-inverse (composing it with itself produces the identity)
and in which composing any two of the three ...
.
Modulo 16 there are eight coprime congruence classes
and
is the 2-
torsion subgroupIn the theory of abelian group
In mathematics
Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (math ...
(i.e., the square of each element is 1), so
is not cyclic. The powers of 3,
are a subgroup of order 4, as are the powers of 5,
Thus
The pattern shown by 8 and 16 holds for higher powers 2
''k'', :
is the 2-torsion subgroup (so
is not cyclic) and the powers of 3 are a cyclic subgroup of order , so
General composite numbers
By the
fundamental theorem of finite abelian groups
In mathematics, an abelian group, also called a commutative group, is a group (mathematics), group in which the result of applying the group Operation (mathematics), operation to two group elements does not depend on the order in which they are ...
, the group
is isomorphic to a
direct productIn mathematics
Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It ha ...
of cyclic groups of prime power orders.
More specifically, the
Chinese remainder theorem
In number theory, the Chinese remainder theorem states that if one knows the remainders of the Euclidean division of an integer
An integer (from the Latin wikt:integer#Latin, ''integer'' meaning "whole") is colloquially defined as a number ...
says that if
then the ring
is the
direct productIn mathematics
Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It ha ...
of the rings corresponding to each of its prime power factors:
:
Similarly, the group of units
is the direct product of the groups corresponding to each of the prime power factors:
:
For each odd prime power
the corresponding factor
is the cyclic group of order
, which may further factor into cyclic groups of prime-power orders.
For powers of 2 the factor
is not cyclic unless ''k'' = 0, 1, 2, but factors into cyclic groups as described above.
The order of the group
is the product of the orders of the cyclic groups in the direct product.
The
exponent
Exponentiation is a mathematical
Mathematics (from Greek
Greek may refer to:
Greece
Anything of, from, or related to Greece
Greece ( el, Ελλάδα, , ), officially the Hellenic Republic, is a country located in Southeast Europ ...
of the group, that is, the
least common multiple
In arithmetic
Arithmetic (from the Ancient Greek, Greek wikt:en:ἀριθμός#Ancient Greek, ἀριθμός ''arithmos'', 'number' and wikt:en:τική#Ancient Greek, τική wikt:en:τέχνη#Ancient Greek, έχνη ''tiké échne', ...

of the orders in the cyclic groups, is given by the
Carmichael function
In number theory, a branch of mathematics
Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathemati ...
.
In other words,
is the smallest number such that for each ''a'' coprime to ''n'',
holds.
It divides
and is equal to it if and only if the group is cyclic.
Subgroup of false witnesses
If ''n'' is composite, there exists a subgroup of the multiplicative group, called the "group of false witnesses", in which the elements, when raised to the power , are congruent to 1 modulo ''n''. (Because the residue 1 when raised to any power is congruent to 1 modulo ''n'', the set of such elements is nonempty.)
One could say, because of
Fermat's Little Theorem
Fermat's little theorem states that if is a prime number, then for any integer , the number is an integer multiple of . In the notation of modular arithmetic, this is expressed as
:a^p \equiv a \pmod p.
For example, if = 2 and = 7, then 27 = ...
, that such residues are "false positives" or "false witnesses" for the primality of ''n''. The number 2 is the residue most often used in this basic primality check, hence is famous since 2
340 is congruent to 1 modulo 341, and 341 is the smallest such composite number (with respect to 2). For 341, the false witnesses subgroup contains 100 residues and so is of index 3 inside the 300 element multiplicative group mod 341.
Examples
''n'' = 9
The smallest example with a nontrivial subgroup of false witnesses is . There are 6 residues coprime to 9: 1, 2, 4, 5, 7, 8. Since 8 is congruent to , it follows that 8
8 is congruent to 1 modulo 9. So 1 and 8 are false positives for the "primality" of 9 (since 9 is not actually prime). These are in fact the only ones, so the subgroup is the subgroup of false witnesses. The same argument shows that is a "false witness" for any odd composite ''n''.
''n'' = 91
For ''n'' = 91 (= 7 × 13), there are
residues coprime to 91, half of them (i.e., 36 of them) are false witnesses of 91, namely 1, 3, 4, 9, 10, 12, 16, 17, 22, 23, 25, 27, 29, 30, 36, 38, 40, 43, 48, 51, 53, 55, 61, 62, 64, 66, 68, 69, 74, 75, 79, 81, 82, 87, 88, and 90, since for these values of ''x'', ''x''
90 is congruent to 1 mod 91.
''n'' = 561
''n'' = 561 (= 3 × 11 × 17) is a
Carmichael number
In number theory, a Carmichael number is a composite number n which satisfies the modular arithmetic
In mathematics
Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical struc ...
, thus ''s''
560 is congruent to 1 modulo 561 for any integer ''s'' coprime to 561. The subgroup of false witnesses is, in this case, not proper; it is the entire group of multiplicative units modulo 561, which consists of 320 residues.
Examples
This table shows the cyclic decomposition of
and a
generating set
In mathematics and physics, the term generator or generating set may refer to any of a number of related concepts. The underlying concept in each case is that of a smaller set (mathematics), set of objects, together with a set of Operation (mathe ...
for ''n'' ≤ 128. The decomposition and generating sets are not unique; for example,
(but
). The table below lists the shortest decomposition (among those, the lexicographically first is chosen – this guarantees isomorphic groups are listed with the same decompositions). The generating set is also chosen to be as short as possible, and for ''n'' with primitive root, the smallest primitive root modulo ''n'' is listed.
For example, take
. Then
means that the order of the group is 8 (i.e., there are 8 numbers less than 20 and coprime to it);
means the order of each element divides 4, that is, the fourth power of any number coprime to 20 is congruent to 1 (mod 20). The set generates the group, which means that every element of
is of the form (where ''a'' is 0, 1, 2, or 3, because the element 3 has order 4, and similarly ''b'' is 0 or 1, because the element 19 has order 2).
Smallest primitive root mod ''n'' are (0 if no root exists)
:0, 1, 2, 3, 2, 5, 3, 0, 2, 3, 2, 0, 2, 3, 0, 0, 3, 5, 2, 0, 0, 7, 5, 0, 2, 7, 2, 0, 2, 0, 3, 0, 0, 3, 0, 0, 2, 3, 0, 0, 6, 0, 3, 0, 0, 5, 5, 0, 3, 3, 0, 0, 2, 5, 0, 0, 0, 3, 2, 0, 2, 3, 0, 0, 0, 0, 2, 0, 0, 0, 7, 0, 5, 5, 0, 0, 0, 0, 3, 0, 2, 7, 2, 0, 0, 3, 0, 0, 3, 0, ...
Numbers of the elements in a minimal generating set of mod ''n'' are
:0, 0, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 3, 1, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 2, 3, 1, 2, 1, 2, 2, 1, 1, 3, 1, 1, 2, 2, 1, 1, 2, 3, 2, 1, 1, 3, 1, 1, 2, 2, 2, 2, 1, 2, 2, 2, 1, 3, 1, 1, 2, 2, 2, 2, 1, 3, 1, 1, 1, 3, 2, 1, 2, 3, 1, 2, ...
See also
*
Lenstra elliptic curve factorization
The Lenstra elliptic-curve factorization or the elliptic-curve factorization method (ECM) is a fast, sub-exponential running time, algorithm for integer factorization, which employs elliptic curves. For general-purpose computer, general-purpose fa ...
Notes
References
The ''
Disquisitiones Arithmeticae
Title page of the first edition
The (Latin
Latin (, or , ) is a classical language belonging to the Italic languages, Italic branch of the Indo-European languages. Latin was originally spoken in the area around Rome, known as Latium. Through ...
'' has been translated from Gauss's
Ciceronian Latin into
English
English usually refers to:
* English language
English is a West Germanic languages, West Germanic language first spoken in History of Anglo-Saxon England, early medieval England, which has eventually become the World language, leading lan ...

and
German
German(s) may refer to:
Common uses
* of or related to Germany
* Germans, Germanic ethnic group, citizens of Germany or people of German ancestry
* For citizens of Germany, see also German nationality law
* German language
The German la ...

. The German edition includes all of his papers on number theory: all the proofs of
quadratic reciprocity
In number theory, the law of quadratic reciprocity is a theorem about modular arithmetic
In mathematics
Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, struc ...
, the determination of the sign of the
Gauss sumIn algebraic number theory
Title page of the first edition of Disquisitiones Arithmeticae, one of the founding works of modern algebraic number theory.
Algebraic number theory is a branch of number theory that uses the techniques of abstract al ...
, the investigations into
biquadratic reciprocity
Quartic or biquadratic reciprocity is a collection of theorems in elementary and algebraic number theory, algebraic number theory that state conditions under which the congruence relation, congruence ''x''4 ≡ ''p'' (mod ''q'') is solvable; ...
, and unpublished notes.
*
*
*
*
External links
*
*{{MathWorld , title=Primitive Root , id=PrimitiveRoot
Web-based tool to interactively compute group tablesby John Jones
Finite groups
Modular arithmetic
Multiplication