You are on page 1of 8

# Residue Classes with Order 1 or 2 and a

## Generalisation of Wilsons Theorem

Yimin Ge
Vienna, Austria

1 Introduction
We start off with a very famous theorem and the usual proof of it:
Theorem 1 (Wilsons Theorem). Let m be a positive integer. Then

(m 1)! 1 (mod m)

## if and only if m is a prime number.

Proof. Suppose first that (m 1)! 1 (mod m) for some positive integer
m. If m is not prime then there exists a divisor d of m with 1 < d < m, so
d|(m 1)!. But d|m, so d| 1, a contradiction. Thus, m must be prime.
Suppose now that m is prime. If some residue class x modulo m has got a
multiplicative inverse1 x1 with x 6 x1 (mod m) then they both drop out
of (m 1)!. Hence, (m 1)! is congruent to the product of all integers x with
1 x m 1 and x2 1 (mod m). However, since m is prime,

x2 1 (mod m)
(x 1)(x + 1) 0 (mod m)
x 1 (mod m) or x m 1 (mod m).

Hence,
(m 1)! 1 (m 1) 1 (mod m).
1
The multiplicative inverse of an integer x modulo a positive integer m is an integer
x modulo m which satisfies xx1 1 (mod m). It is well known that x1 exists if and
1

## only if gcd(x, m) = 1 and furthermore if x1 exists then it is unique modulo m.

1
2 A Generalisation of Wilsons Theorem
While the only if -part is trivial, the proof of the if -part of Wilsonss The-
orem contains certain thoughts which can be adapted for one of the many
generalisations of Wilsons Theorem, which is usually credited with Euler.
Proposition 1. Let m 2 be a positive integer and let T (m) be the product
of all integers x with 1 x m and gcd(x, m) = 1, that is,
Y
T (m) := x.
1xm
gcd(x,m)=1

Then (
1 if m = 2, 4, pk , 2pk
T (m) (mod m),
1 else
where p is an odd prime number and k a positive integer.
The trained eye will recognize the numbers m for which T (m) 1 (mod m)
as exactly the numbers modulo which primitive roots exist. A more detailled
relation between these results requires deeper knowledge of algebra (in par-
ticular group theory) and is rudimentarily discussed in Section 3.
The main idea of the proof of Proposition 1 is very similar to the proof of the
if -part of Wilsons Theorem, for the concrete implementation, we however
shall require some more theory.
Defninition 1. Let m 2 be a positive integer. Then A(m) denotes the set
of all integers x coprime to m with 1 x m having order2 1 or 2, that is

## A(m) := {x Z | 1 x m, x2 1 (mod m)}.

Let furthermore (m) := |A(m)| and let P (m) be the product of all elements
in A(m), that is, Y
P (m) := x.
xA(m)

## The first step in proving Proposition 1 is reducing T (m) to P (m), as we have

done it in the proof of Theorem 1.
2
The order of an integer x modulo m is the least positive integer t so that xt 1
(mod m). It exists if and only if gcd(x, m) = 1 and is denoted by ordm (x).

2
Lemma 1. Let m 2 be an integer. Then

## Proof. Suppose that x {1, . . . , m} is an integer coprime to m. If the

multiplicative inversive x1 of x satisfies x 6 x1 (mod m), then both x and
x1 drop out of T (m). Thus, the only numbers left in T (m) are those residue
classes modulo m which are their own multiplicative inversives respectively
and the set of those residue classes is defined as A(m).
Notice that if m 3 is an integer, then (m) is even since if x2 1 (mod m),
then we also have (x)2 1 (mod m). It is also easy to see that

## Lemma 2. Let m 3 be a positive integer. Then

P (m) (1)(m)/2 .

Proof. We have
Y Y Y
P (m) = x= x x(x)
xA(m) 1xm 1x m2

m|(x2 1) m|(x2 1)
Y Y
= x2 1 = (1)(m)/2 (mod m).
1x m2
1x m2

m|(x2 1) m|(x2 1)

We thus see that when analyzing P (m), it is not necessary to know the exact
residue classes in A(m) but sufficient to know only the number of them. In
the following, we will find a general formula for (m).

## Lemma 3. We have (1) = 1, (2) = 1, (4) = 2.

Proof. This directly follows from a trivial inspection: we have A(1) = {1},
A(2) = {1} and A(4) = {1, 3}.

## Proof. Notice that x must be odd in order to be in A(2k ). We have

x2 1 (mod 2k )
(x 1)(x + 1) 0 (mod 2k ). (1)

3
Since x 1 and x + 1 are two consecutive even integers, (1) is equivalent to

## Lemma 5. Let p be an odd prime number and let k be a positive integer.

Then (pk ) = 2.

Proof. We have

x2 1 (mod pk )
(x 1)(x + 1) 0 (mod pk ). (2)

## Since p is an odd prime number, x 1 and x + 1 cannot be both divisible by

p. Thus, (2) is equivalent to

x 1, 1 (mod pk ),

so
A(pk ) = {1, pk 1}
and hence, (pk ) = 2.
It thus remains to find (m) for composite numbers m.

Lemma 6. The function is multiplicative, that is, for all positive integers
m, n with gcd(m, n) = 1 we have

(mn) = (m)(n).

4
Proof. Suppose that y1 , . . . , y(m) A(m) and z1 , . . . , z(n) A(n) are the
residues modulo m and n with order 1 or 2 respectively. Then x2 1
(mod mn) holds if and only if

## x yi (mod m) and x zj (mod n)

for some integer i with 1 i (m) and some integer j with 1 j (n).
Obviously there are (m)(n) ways to choose such a pair (i, j) and since we
get a different residue modulo mn in A(mn) for different pairs (i, j) by the
chinese remainder theorem3 , we obtain (mn) = (m)(n).
From Lemma 3 to 6, we obtain the following formula for (m):
Theorem 2. Let m = 2k pk11 . . . pkr r be the prime factorization of a positive
integer m (r 0, k 0, ki 1). Then

r
2
if k 1
(m) = 2 r+1
if k = 2

r+2
2 if k 3.

## From this formula, we immediately infer

Corollary 1. Let m 2 be an integer. Then (m) is not divisible by 4 if
and only if m = 2, 4, pk , 2pk , where p is an odd prime number and k is a
positive integer.
It follows now from Corollary 1, Lemma 1 and Lemma 2 that
(
1 if m = 2, 4, pk , 2pk
T (m) P (m) (mod m),
1 else

## which proves Proposition 1.

3
The Chinese Remainder Theorem states that if m1 , . . . , mr are pairwise coprime pos-
itive integers and x1 , . . . , xr are arbitrary integers, then the system of congruences

x x1 (mod m1 )
..
.
x xr (mod mr )

## has an integer solution in x. Furthermore, this solution is unique modulo m1 . . . mr .

5
3 Prospects
From a much more advanced point of view, we know from the Chinese Re-
mainder Theorem that

## (Z/mZ) (Z/p1 1 Z) (Z/pr r Z)

holds for any positive integer m 2 having the canonical prime factorization
m = p1 1 . . . pr r .
Furthermore,
(
i C(pi i ) if primitive roots modulo pi i exist
(Z/pi Z)
C2i 2 C2 if pi = 2 and i 3,

## where (Ca , ) (Z/aZ, +) is a cyclic group of order a in multiplicative nota-

tion.
However, (pi i ) is either 1 or even, so if we assume that m > 2 (which means
(Z/mZ) is nontrivial), then we have found a decomposition of (Z/mZ) into
cyclic groups of even order, that is,

## where m1 , . . . , mk are even positive integers. Indeed, we can assume that

m1 , . . . , mk are even positive integers since the trivial group C1 (Z/2Z)
drops out of this decomposition if it exists.
In this configuration, (Z/mZ) is obviously cyclic if and only if k = 1 since
Cab Ca Cb holds if and only if gcd(a, b) = 1.
Suppose now that g1 , . . . , gk are generators of Cm1 , . . . , Cmk respectively. As
usual, we identify gi as the tupel (1, . . . , 1, gi, 1, . . . , 1). Then
| {z } | {z }
i1 ki

Y Y
x= g1a1 . . . gkak .
x(Cm1 ...Cmk ) 0ik
0ai <mi

## For every integer ai with 0 ai mi , giai appears exactly m1 . . . mk /mi

6
times in this product. Hence,
Y m1 ...mk Pm1 m1 ...mk Pmk
a1 ak m1 a1 =0 a1 m ak =0 ak
g1 . . . gk = g1 . . . gk k
i=1,...,k
0ai <mi
m1 ...mk m1 (m1 1) m1 ...mk mk (mk 1)
m1 2 mk 2
= g1 . . . gk
m1 ...mk (m1 1) m1 ...mk (mk 1)
= g1 2
. . . gk 2
.

But g1l1 . . . gklk = 1 holds if and only if mi |li for all i = 1, . . . , k since we are
working with a direct product. Thus,
m1 ...mk (m1 1) m1 ...mk (mk 1)
g1 2
. . . gk 2
=1
holds if and only if we have
m1 . . . mk
mi | (mi 1) (3)
2
for all i = 1, . . . , k. But we know that m1 , . . . , mk are even, so (3) holds if
and only if k > 1 which in other words means that (Z/mZ) is not cyclic. If
k = 1 then
m1 (m1 1) m1 m1 (m1 1)
m1 but | ,
2 2 2
so
m1 (m1 1) m1
(mod m1 ).
2 2
Thus, if g is a primitive root modulo m, then
Y m1 (m1 1) m1
x=g 2 = g 2 = 1.
x(Z/mZ)

Hence, (
Y 1 if (Z/mZ) is cyclic
x=
x(Z/mZ)
1 else
which is just the claim of Proposition 1.

We see that the proof works not only with (Z/mZ) but with any finite
abelian group G which can be written as a product of cyclic groups of even
order. Therefore, we obtain the following generalisation:

7
Corollary 2. Let m1 , . . . , mk be positive integers and suppose that

G Cm1 . . . Cmk

Y
x 6= 1
xG