# Modular operation

Time：2021-5-3

### Modular operation

Suppose that \\\\\\\\\\\\\\\\. If M is divided by a – R, it can be recorded as:\\

### Calculation of remainder

You can always find a a in Z so that

A = q · m + R, where 0 / Leq r < m

Since a – r = q · m (M divided by A-R), the expression of appeal can be written as: A / equiv / R / mod / M (R / in {1,2,…, m-1)}

Example: suppose a = 42, M = 9, then 42 = 4.9 + 6

So 42 / equiv6 / mod / 9

### The remainder is not unique

Consider a strange problem: for each given modulus m and integer a, there may be infinitely many effective remainders at the same time. Here’s another example.

Example: consider a = 12, M = 9. According to the previous definition, the following results are correct:

• 12 = 3 mod 9, 3 is a valid remainder because 9 (12 – 3)
• 12 = 21 mod 9, 21 is a valid remainder because 9 (21 – 3)
• 12 = – 6, mod 9, – 6 is a valid remainder because 9 (- 6 – 3)

Where x | y is x divided by y. Behind this operation is a system. Integer set

\left\{…,-24,-15,-6,3,12,21,30,…\right\}

There are eight other equivalence classes in module 9

\left\{…,-27,-18,-9,0,9,18,27,…\right\}\\
\left\{…,-26,-17,-8,1,10,19,28,…\right\}\\
·\\
·\\
·\\
\left\{…,-19,-10,-1,8,17,26,35,…\right\}

### The behavior equivalence of all members in equivalence class

For a given modulus m, the result of selecting any element in the equivalence class for calculation is the same. This property of equivalence class is of great practical significance. In the computation of fixed modulus, which is also the most common case in cryptography, we can choose the most computable element in the equivalence class.

Of course, no matter how to switch in the equivalence class, the final result of any modulus calculation is the same.

### The choice of remainder

Generally, R is chosen to satisfy the following conditions:

0\leq r\leq m-1

But from a mathematical point of view, the choice of any element in the equivalence class has no effect on the final result.