# Dom::IntegerMod

Residue class rings modulo integers

## Syntax

### Domain Creation

`Dom::IntegerMod(`n`)`

### Element Creation

`Dom::IntegerMod(n)(`a`)`

## Description

### Domain Creation

`Dom::IntegerMod(n)` creates the residue class ring of integers modulo `n`.

`Dom::IntegerMod(n)` creates the integer residue class rings .

### Element Creation

`Dom::IntegerMod(n)(a)` creates the residue class of `a` modulo `n`.

## Superdomain

`Dom::BaseDomain`

## Categories

If `n` is prime, then `Cat::Field`, else `Cat::CommutativeRing`.

## Examples

### Example 1

We define the residue class ring of the integers ```mod 7```:

`Z7:= Dom::IntegerMod(7)`

Next, we create some elements:

`a:= Z7(1); b:= Z7(2); c:= Z7(3)`

We may use infix notation for arithmetical operations since the operators have been overloaded:

`a + b, a*b*c, 1/c, b/c/a/c`

`a` and `b` are squares while `c` is not:

`Z7::isSquare(a), Z7::isSquare(b), Z7::isSquare(c)`

Indeed, `c` is a generator of the group of units:

`Z7::order(a), Z7::order(b), Z7::order(c)`

## Parameters

 `n` Positive integer greater than 1 `a` Any integer or a rational number whose denominator is coprime to `n`

## Entries

 "characteristic" the characteristic of the residue class ring, `n` "one" the unit element, `1 mod n` "zero" the zero element, `0 mod n`

collapse all

## Mathematical Methods

### `_divide` — Division of two elements

`_divide(element1, element2)`

### `_invert` — Invert elements

`_invert(element)`

### `_mult` — Multiply elements

`_mult(element, …)`

### `_negate` — Negate elements

`_negate(element)`

### `_plus` — Add elements

`_plus(element, …)`

### `_power` — Power of elements

`_power(element, power)`

### `_subtract` — Subtraction of two elements

`_subtract(element1, element2)`

### `associates` — Test for associate elements

Inherited from `Cat::Field`.

### `divide` — Division with remainder

Inherited from `Cat::Field`.

### `divides` — Test if division is exact

Inherited from `Cat::Field`.

### `euclideanDegree` — Return Euclidean degree

Inherited from `Cat::Field`.

### `factor` — Unique factorization

Inherited from `Cat::Field`.

### `gcd` — Greatest common divisor

Inherited from `Cat::Field`.

### `irreducible` — Test if element is irreducible

Inherited from `Cat::Field`.

### `isUnit` — Test if element is an unit

Inherited from `Cat::Field`.

### `isone` — Test if element is one

Inherited from `Cat::Monoid`.

### `quo` — Return Euclidean quotient

Inherited from `Cat::Field`.

### `rem` — Return Euclidean remainder

Inherited from `Cat::Field`.

### `sqrfree` — Square-free factorization

Inherited from `Cat::Field`.

### `isSquare` — Test for being a square

`isSquare(element)`

### `iszero` — Zero test

`iszero(element)`

### `ln` — Discrete logarithm

`ln(element, base)`

The result is `infinity` if `element` is not in the subgroup generated by `base`.

The result is `FAIL` if `base` is not a unit.

### `order` — Order

`order(element)`

The result is `FAIL` if `element` is not a unit.

## Conversion Methods

### `TeX` — TeX output

`TeX(element)`

### `convert` — Conversion

`convert(number)`

The conversion fails if the denominator of `number` and the modulus `n` are not relatively prime.

### `convert_to` — Conversion

`convert_to(element, d)`

### `expr` — Convert an element to an expression

`expr(element)`

## Technical Methods

### `print` — Printing elements

`print(element)`

### `random` — Random element

`random()`

### `unitNormal` — Unit normal form

Inherited from `Cat::Field`.

### `unitNormalRep` — Unit normal representation

Inherited from `Cat::Field`.