The basic facts about congruences can be found in any Number Theory book. We will merely review them here. For details please consult any standard text on number theory.

For any integer we say that two integers a and b are congruent modulo n or if n divides the difference a-b.

For example, 5 and 11 are congruent modulo 3:

11≡5(mod 3) because 11 − 5 gives 6, which is divisible by 3. Or, equally, both numbers give the same remainder when divided by 3:

11 = 3×3 + 2 5 = 1×3 + 2

If a1 ≡ b1 (mod n) and a2 ≡ b2 (mod n) then a1 + a2 ≡ b1 + b2 (mod n) and a1a2 ≡ b1b2 (mod n) This turns the congruence (mod n) into an equivalence on the ring of all integers. The equivalence class of the integer *a*, denoted by , is the set . This set, consisting of the integers congruent to *a* modulo *n*, is called the **congruence class** or **residue class** of *a* modulo *n*. Another notation for this congruence class, which requires that in the context the modulus is known, is .

The set of congruence classes modulo *n* is denoted as (or, alternatively, or ) and defined by:

has *n* elements, and can be written as:

We can define addition, subtraction, and multiplication on by the following rules:

The verification that this is a proper definition uses the properties given before.

In this way, becomes a commutative ring. In fact, it turns out that is a field (which is a special kind of a commutative ring) if and only if n is a prime number.

**Fermat's little theorem** (not to be confused with Fermat's last theorem) states that if *p* is a prime number, then for any integer *a*, will be evenly divisible by *p*. This can be expressed as follows:

The totient function of a positive integer *n* is defined to be the number of positive integers less than or equal to *n* that are coprime to *n*. For example, since the six numbers 1, 2, 4, 5, 7 and 8 are coprime to 9.

**Euler's theorem** (also known as the **Fermat-Euler theorem** or **Euler's totient theorem**) states that if *n* is a positive integer and *a* is coprime to *n*, then

where φ(*n*) is Euler's totient function and "... ≡ ... (mod *n*)" denotes congruence modulo n.

The theorem is a generalization of Fermat's little theorem.