The nature of the same remainder operation

Source: Internet
Author: User
Tags modulus

The remainder of 100 divided by 7 is 2, meaning that 100 items seven seven are divided into one group and the last 2 are left. The remainder has a strict definition: if dividend is a and the divisor is B (assuming they are all positive integers), then we can always find a natural number less than B r and an integer m, making the a=bm+r. This r is the remainder of a divided by B, and M is called quotient. We often use MoD to represent the remainder, a divided by B R is written a mod B = r.
If the difference between two numbers A and b can be divisible by M, then we say A and b are equal to modulus m (about M congruence). For example, 100-60 divided by 8 is exactly the same, we say 100 and 60 for modulo 8 congruence. Another implication of this is that the remainder of 100 and 60 divided by 8 is the same. A and B are equal to M, and we are credited as A≡b (mod m). For example, just the example can be written as 100≡60 (mod 8). You will find that this notation is used everywhere, for example, in books related to number theory, a mod 3 = 1 is often written a≡1 (mod 3).
The reason for the congruence as an operation is because the congruence satisfies the many properties of the operation. For example, congruence satisfies the equivalence relationship. Specifically, it satisfies reflexivity (a number is always the same as itself), symmetry (A and B congruence, B and A are also congruence) and transitivity (A and B congruence, B and C with the same remainder can be introduced A and C). All three of these properties are obvious.
There are slightly more complex properties in the congruence operation. For example, the same remainder operation and the integer addition and subtraction satisfies the same equal and equal amount, and it is unchanged. Elementary school we know that an equal number can be added to both sides of the equation. For example, A=b can launch a+100=b+100. Such a property in the same operation also has: for the same modulus m, if A and B congruence, X and y congruence, then a+x and B+y are also the same remainder. In my opinion, this conclusion is almost obvious. Of course, we can also strictly prove this theorem. This theorem is equally effective for subtraction.

Nature: If A≡b (mod m), X≡y (mod m), then A+x≡b+y (mod m).
Proof: The condition tells us that p and Q can be found so that a-mp = B-mq, also exists R and s makes X-MR = Y-ms. So a-mp + X-MR = b-mq + Y-ms, i.e. a+x-m (p+r) = B+y-m (q+s), this tells us that a+x and b+y divide by M for the same remainder.

It is easy to think that two identical equivalents are multiplied, and still equal on both sides of the same equation:
If A≡b (mod m), X≡y (mod m), then Ax≡by (mod m).
Proof: The condition tells us that a-mp = B-MQ,X-MR = Y-ms. So (A-MP) (X-MR) = (B-MQ) (y-ms), the equation on both sides of the separate expansion must be ax-m (...) = By-m (...) The form, which explains Ax≡by (mod m).

Now you know why some questions call you "output answer mod xxxxx results", that is to avoid high-precision operations, because the conclusion here tells us that in the process of calculating the side of the MoD and after the results of the MoD. If a is a large number, so that b=a mod m, then the result of mod m and (b *) mod m is exactly the same, which is equivalent to multiplying by 100 on both sides of the a≡b (mod m). These conclusions are obviously, because the same remainder operation only cares about the residue (not the "whole part"), it can only retain the remainder after every operation. Therefore, the number of participating operations in the whole operation is no more than M, avoiding the appearance of high precision.

In proving the Fermat small theorem, we used a theorem like this:
If AC≡BC (mod m), and C and M coprime, then a≡b (mod m) (that is, both sides of the same can be divided by one and a modulo coprime).
Proof: The condition tells us that ac-mp = bc-mq, the moving term can be AC-BC = mp-mq, i.e. (A-b) c = m (p-q). This shows that (A-B) c is required to contain factor m, but C and M coprime, so it is possible that the only B is divisible by M, i.e. A≡b (mod m).

Original Author: Matrix67

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.