China residue theorem and Residue Theorem

Source: Internet
Author: User

China residue theorem and Residue Theorem

Introduction to China Residue Theorem

 In Sun Tzu's computing Sutra, there is a problem: "I don't know the number of things today, but the number of three is two (divided by more than three 2 ), three of the five remaining values (divided by more than 5 3), two of the seven remaining values (divided by more than 7 2), and asked ry?" This problem is called the "Sun Tzu's Problem". The general solution of this problem is internationally referred to as the "China Surplus Theorem ". The solution consists of three steps:


Analysis:


We split the "Sun Tzu's question" into several simple small problems, starting from scratch, trying to speculate on how the ancients pushed this solution.

First, let us assume that n1 is a number that satisfies dividing by 3 more than 2, such as 2, 5, 8, and so on, that is, an arbitrary number that satisfies 3 * k + 2 (k> = 0. Similarly, we assume that n2 is a number that satisfies the division by more than 5 3, and n3 is a number that satisfies the division by more than 7 2.

With the preceding assumption, we first start from the perspective of n1. If we know that n1 is satisfied by dividing by 3 + 2, can we make the sum of n1 + n2 still meet the condition of dividing by 3 + 2? So that the sum of n1 + n2 + n3 is still divided by 3 + 2?

This involves a basic mathematical theorem. If a % B = c exists, (a + kb) % B = c (k is a non-zero integer). In other words, if the remainder of a division operation is c, the sum (difference) of the addition (or subtraction) of the divisor and k times is then divided with the divisor, and the remainder remains unchanged. This is a good proof.

Based on this theorem, if n2 is a multiple of 3, n1 + n2 can still be divided by 3 + 2. Similarly, if n3 is a multiple of 3, the sum of n1 + n2 + n3 is divided by 3 and 2. This is from the perspective of n1. From the perspective of n2 and n3, we can export the following three points:

  1. In order to divide the sum of n1 + n2 + n3 by 3 + 2, n2 and n3 must be multiples of 3.
  2. In order to divide the sum of n1 + n2 + n3 by more than 5 3, n1 and n3 must be multiples of 5.
  3. To divide the sum of n1 + n2 + n3 by more than 7 2, n1 and n2 must be multiples of 7.

Therefore, to enable the sum of n1 + n2 + n3 as a final solution to the "Sun Tzu problem", we need to meet the following requirements:

  1. N1 is divided by more than 3 2 and is a public multiple of 5 and 7.
  2. N2 is divided by more than 5 3 and is a public multiple of 3 and 7.
  3. N3 is divided by more than 7 2 and is a public multiple of 3 and 5.

Therefore, the essence of Sun Tzu's solution is to find a number n1 divided by 3 and 2 in the public multiples of 5 and 7, find a number n2 divided by more than 5 3 from the public multiples of 3 and 7, and find a number n3 divided by more than 7 2 from the public multiples of 3 and 5, then, add the three numbers to obtain the solution. I used a small trick to evaluate n1, n2, and n3. Taking n1 as an example, we did not directly find a number divided by 3 and 2 from the public multiples of 5 and 7, instead, first find a number divided by 3 and then multiply by 2.

Here is another mathematical formula. If a % B = c, (a * k) % B = a % B +... + A % B = c +... + C = kc (k> 0). That is to say, if the remainder of a division is c, the remainder of the devisor k times the division is kc. Proof in expansion.

Finally, we need to be clear that n1 + n2 + n3 is only a solution to the problem, not the smallest solution. How do I obtain the explain solution? We only need to minimize the loss of the Public multiples of 3, 5, and 7 by 105. The truth is the previous theorem "if a % B = c, there is (a-kb) % B = c ". Therefore (n1 + n2 + n3) % 105 is the final solution.







China Remainder Theorem

Zhidao.baidu.com/question/18353561.html
Take a look.
Sun Tzu's computation Sutra provides solutions to these problems: "If there are only two in three, one hundred and forty is left; if there are three in five, is left; if there are two in seven, then thirty is left; and get two hundred and thirty-three, minus two hundred and ten, that is, get. If there is one left in three or three, 70 is set; if there is one left in five, 21 is set; if there is one left in seven, 15, one hundred and six, and more are set to one hundred and five,." In modern languages, this solution is:

First, find the number of 70 which can be divisible by 5 and 7 and divided by 3 and 1, and divide by 3 and 7, and divide by 5 and then divide by 21, divided by 3 and 5, and divided by 7, the number of 1 is 15.

If the number is 3 to 2, the number 70 × 2 = 140,140 is the number of 3 to 2 divided by 5 and 7.

If the number is divided by 5 to 3, the number 21 × 3 = 63,63 is the number divided by 3 and 7 and divided by 5 to 3.

If the number is 7 to 2, the number is 15 × 2 = 30, and 30 is the number of 7 to 2 divided by 3 and 5.

Again, 140 + 63 + 30 = 233. Because both 63 and 30 can be divisible by 3, the remainder of 233 and 140 is the same, both of which are equal to 2, similarly, the remainder of 233 and 63 are the same as those of 5, and the remainder of 3,233 and 30 are the same as those of 7, both of which are 2. Therefore, 233 is a number that meets the question requirements.

The minimum public multiples of 3, 5, and 7 are 105. Therefore, the remainder divided by 3, 5, and 7 is not changed after 233 is an integer multiple of 105, the number can meet the requirements of the question. Because the number of soldiers requested is only one team, which means that the number of soldiers should not exceed 100, so 233 minus 105 to 2 times 23 is the demand.

China Remainder Theorem

Zhidao.baidu.com/question/18353561.html
Take a look.
Sun Tzu's computation Sutra provides solutions to these problems: "If there are only two in three, one hundred and forty is left; if there are three in five, is left; if there are two in seven, then thirty is left; and get two hundred and thirty-three, minus two hundred and ten, that is, get. If there is one left in three or three, 70 is set; if there is one left in five, 21 is set; if there is one left in seven, 15, one hundred and six, and more are set to one hundred and five,." In modern languages, this solution is:

First, find the number of 70 which can be divisible by 5 and 7 and divided by 3 and 1, and divide by 3 and 7, and divide by 5 and then divide by 21, divided by 3 and 5, and divided by 7, the number of 1 is 15.

If the number is 3 to 2, the number 70 × 2 = 140,140 is the number of 3 to 2 divided by 5 and 7.

If the number is divided by 5 to 3, the number 21 × 3 = 63,63 is the number divided by 3 and 7 and divided by 5 to 3.

If the number is 7 to 2, the number is 15 × 2 = 30, and 30 is the number of 7 to 2 divided by 3 and 5.

Again, 140 + 63 + 30 = 233. Because both 63 and 30 can be divisible by 3, the remainder of 233 and 140 is the same, both of which are equal to 2, similarly, the remainder of 233 and 63 are the same as those of 5, and the remainder of 3,233 and 30 are the same as those of 7, both of which are 2. Therefore, 233 is a number that meets the question requirements.

The minimum public multiples of 3, 5, and 7 are 105. Therefore, the remainder divided by 3, 5, and 7 is not changed after 233 is an integer multiple of 105, the number can meet the requirements of the question. Because the number of soldiers requested is only one team, which means that the number of soldiers should not exceed 100, so 233 minus 105 to 2 times 23 is the demand.

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: info-contact@alibabacloud.com 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.