Definition

Let be the modulus, an integer The set of all integers congruent to is called the congruence class of modulo It is denoted as

Definition

The set of all congruence classes modulo is denoted (read mod )

There are some elements for which there exists a multiplicative inverse

Which is denoted as , if it is unique and exists

Theorem

In , we have the equivalent statements:

  1. has the inverse
  2. For all has a unique solution
  3. There exists such that has a unique solution

Theorem

Let be an integer The element has a unique multiplicative inverse >

Theorem

If is prime, all elements of except have a multiplicative inverse

Euclid and Bézout

Theorem (Euclid)

Let be non-zero integers. Then for

This means that we can make a simple gcd algorithm:

Algorithm

fn gcd(a: i32, b: i32) -> i32 {
	return if a < b {
		gcd(b, a)
	} else if b == 0 {
		a
	} else {
		gcd(b, a % b)
	}
}

Theorem (Bézout)

Let and be integers, There are integers and such that

With that, we can draw another algorithm:

Algorithm

fn euclid(a: i32, b: i32) -> (i32, i32, i32) {
	return if a < b {
		euclid(b, a)
	} else if b == 0 {
		(1, 0, a)
	} else {
		let q: i32 = a / b;
		let r: i32 = a % b;
		let (u, v, d) = euclid(b, r);
		(v, u - v * q, d) 
	}
}

Corollary

> there exists integers and s.t

02.4 Commutative Groups