Modulo p operation
Given a positive integer p, any integer n must have an equation
n = kp + r
Where K and R are integers and 0 ≤ r <p. k is the quotient of n divided by P, and r is the remainder of n divided by P.
For positive integers p and integers A and B, the following operations are defined:
- Modulo operation: A mod p indicates the remainder of a divided by P.
- Mod P addition :( a + B) mod P, the result is the remainder of A + B arithmetic and divided by P, that is, (a + B) = KP + R, then (a + B) mod p = R.
- Modulo p subtraction: (a-B) mod P. The result is the remainder of a-B arithmetic difference divided by P.
- Modulo p multiplication: (A × B) mod P. The result is the remainder of a × B arithmetic multiplication divided by P.
We can find that there are many similar rules between the modulo p operation and the ordinary four arithmetic operations, such:
Rule |
Formula |
Combination Rate |
(A + B) mod p + C) mod p = (a + (B + C) mod p (A * B) mod p * C) mod p = (A * (B * C) mod p |
Exchange Rate |
(A + B) mod p = (B + a) mod p (A × B) mod p = (B × A) mod p |
Allocation rate |
(A + B) mod p × c) mod p = (A × c) mod p + (B × c) mod p |
The first formula is as follows:
(A + B) mod p + C) mod p = (a + (B + C) mod p
Hypothesis
A = k1 P + r1
B = k2 P + R2
C = K3 P + r3
A + B = (K1 + K2) P + (R1 + R2)
If (R1 + R2)> = P, then
(A + B) mod p = (R1 + R2)-P
Otherwise
(A + B) mod p = (R1 + R2)
Then perform the P and operation with C to obtain
The result is the arithmetic sum of R1 + r2 + R3 and the remainder of P.
Calculate the right side to get the same result.
Equal modulo p
If two numbers A and B meet a mod p = B mod P, the modulo p is equal.
A challenge B mod p
It can be proved that a and B satisfy a = KP + B, where k is an integer.
For the modulo p equality and modulo p multiplication, there is a rule that is very different from the four arithmetic operations. In the four arithmetic operations, if C is a non-0 integer
AC = BC, A = B can be obtained.
However, in the P operation, this relationship does not exist, for example:
(3x3) mod 9 = 0
(6x3) mod 9 = 0
However
3 mod 9 = 3
6 mod 9 = 6
Theorem (Elimination Law): If gcd (C, p) = 1, AC ≡ BC mod P can launch a ≡ B mod p
Proof:
Because AC hybrid BC mod p
So AC = BC + KP, that is, C (a-B) = Kp
Because C and P do not have any common factor except 1, the above formula must meet one of the following two conditions.
1) C can divide K
2) A = B
If 2 is not true, c | KP
Because C and P do not have a common factor, it is clear that c | K, So k = ck'
Therefore, C (a-B) KP can be expressed as C (a-B) = ck 'P
Therefore, a-B = k'p is obtained, and a ≡ B mod P is obtained.
If A = B, A then B mod P is obviously true.
Pass
Euler's Function
Euler's function is a very important function in number theory. Euler's function refers to the number of positive integers with positive integers n, less than N, and interlace with N ), here, Phi (1) is defined as 1, but there is no substantive significance.
Defines a set of numbers less than N and with N mutual quality as Zn, and calls this set a complete remainder set of N.
Obviously, for the prime numbers P, Phi (p) = p-1. For the two prime numbers p and q, their product N = PQ satisfies)
Proof: for prime number p, q, meet)
Consider n's full remainder set ZN = {1, 2,..., PQ-1}
Instead, a collection that does not interact with N is composed of the following three sets:
1) can be P integer division of the set {P, 2 p, 3 P,..., (q-1) p} A total of q-1
2) the total number of {q, 2q, 3q,..., (p-1) Q} sets that can be divisible by Q:
3) {0}
Obviously, there are no common elements in the 1 and 2 sets, so the number of elements in Zn = PQ-(p-1 + q-1 + 1) = (p-1) (q-1)
Euler's Theorem
For integers A and N of the mutual quality, there is a Phi (n) limit 1 mod n
Proof:
First, we will prove the following proposition:
For the set ZN = {x1, x2,..., x phi (n)}, consider the set
S = {ax1 mod N, ax2mod N,..., ax PHI (n) mod n}
Then S = Zn
1) because a and n are mutually qualitative, and XI is also mutually qualitative with N, Axi is also set to P. Therefore
Any XI and Axi mod n must be an element of Zn.
2) for the two elements XI and XJ in Zn, if Xi is less than XJ
Then, Axi mod n = Axi mod N, which can be obtained from the mutual quality and elimination law of a and P.
So, obviously, S = Zn
In this case
(Ax1 × ax2 ×... × ax PHI (N) mod n
= (Ax1 mod n × ax2mod n ×... × ax PHI (n) mod n
= (X1 × X2 ×... × x PHI (N) mod n
Consider the left and right sides of the equation above
The left side is equal to (a Phi (n) × (x1 × X2 ×... × x PHI (N) mod n
The right side is equal to X1 × X2 ×... × x PHI (N) mod n
And X1 × X2 ×... × x PHI (N) mod N and P
According to the elimination law, we can get the following from the two sides of the equation:
A Phi (n) limit 1 mod nInference: For the numbers a and N of the mass, the numbers a? (n) + 1? A mod nFerma Theorem
A is a positive integer that cannot be divisible by prime number P, then there is a AP-1 limit 1 mod p
This theorem is very simple. It can be proved by using the Euler's theorem because of the (p) P-1.
Likewise, it is inferred that for a positive integer a that cannot be divisible by prime number P, there is an AP between a mod p