Introduction to the conversion and Division Algorithms

In number theory, the moving phase division (generally referred to as Euclidean algorithm or Euclid's algorithm internationally, that is, the Euclidean Algorithm) is a unit (for example: integer. An important feature of this algorithm is that it does not need to break down the formula to obtain the maximum common number. The transfer and division method is a common algorithm used in computer programming to calculate the maximum common number because of its ease of operation and realization.

Process description and Application of moving phase division

Two natural numbers are given.**A**And**B**: Check**B**Whether it is 0; If yes**A**Is the maximum number of public approx. If not, use**B**And**A**Division**B**As the remainder**A**And**B**Repeat this check procedure.

As mentioned above, the moving phase division is a common algorithm used in programming to calculate the maximum common number. Below is an example of a program segment in C ++ that implements the moving phase division by recursion:

int gcd(int a, int b){ return b == 0 ? a : gcd(b, a % b);}

Note: The process name is set**GCD**It is to clearly indicate the intention of this program. Because**GCD**Yes**Greatest Common Divisor**The abbreviation of (maximum common divisor. The process of calculating the maximum common divisor by the division of the moving phase is: it is best to name it**GCD**To facilitate others' reading in the future.

Proof of division of Moving Phase

Set the number to a and B (A> B), and perform the following steps to calculate their maximum public approx:

Set q = A/B, r = A % B, and obtain a = BQ + R (0 ≤ r <B ).

1) if r = 0, B is the maximum common divisor of A and B.

2) if R is less than 0, proceed with consideration. First of all, we should understand that any common divisor of A and B is the common divisor of R. To prove this, you must write r as R = A-BQ. Now, if A and B have a common divisor D with a = SD, B = TD, then R = SD-tdq = (S-TQ) d. In this formula, all numbers (including S-TQ) are integers, so R can be divisible by D. This is correct for all values of D. Therefore, the maximum common divisor of A and B is also the maximum common divisor of B and R. Therefore, we can continue

B and R perform the remainder operation. After a finite number of duplicates in this process, we can finally get the result of r = 0, and we will get the maximum public approx. of A and B.

Minimum Public multiple proof:

Least common multiple = product of two numbers/maximum common number (you can understand short Division)

Proof:

Set the numbers A and B to GCD and LCM.

Then a = K1 * GCD, B = k2 * GCD

LCM = A * T1 = K1 * GCD * T1 = p * K1;

LCM = B * t2 = k2 * GCD * t2 = Q * K2;

Because gcd (K1, K2) = 1, LCM = K1 * K2 * GCD = a * B/GCD;

Therefore, the least common factor = the product of two numbers/the maximum common number

Certificate 2:

Because K1 * GCD * T1 = LCM = k2 * GCD * t2

And K1, K2, T1, T2, so k1 = T2, K2 = T1;

Substitute LCM = K1 * GCD * T1 = K1 * K2 * GCD = a * B/GCD;

Therefore, the least common factor = the product of two numbers/the maximum common number

The product of the maximum and least common multiples of two numbers is equivalent to the product of the two numbers:

Proof: Let's set two numbers A and B. Their maximum common divisor is P, and the minimum public multiple is Q, so:

A = PM, B = pN, A = Q/e, B = Q/d .............................................. ①

We can see from the definitions of the maximum common divisor and the minimum common multiple that M interacts with N, and E and D are also mutually dependent ....... ②

From ①: M/N = D/E, and then from ② continue to learn: M = d, n = E

AB = PM × Q/D = PQ × m/D = PQ, AB = PQ

Original Certificate. And the product of the maximum and least common multiples of the two numbers are equal to the product of the two numbers.