Toss and tear apart. Algorithm introduction: Divide two numbers A and B, if the remainder C is not equal to 0, give the value of B to A and the value of C to B until C is equal to 0. At this time, the greatest common divisor is B.
More phase subtraction. The algorithm is introduced: subtract the larger number A from the smaller number B. If the difference C is equal to 0, then the greatest common divisor is B. If it is not equal to 0, give the value of B to A and the value of C to B, and continue the subtraction until the difference is equal to 0.
Introduction to the algorithm of exhaustive method: Assign the smaller value of two numbers, A and B, to I, A divided by I, and B divided by I. If the remainder of the two numbers is 0 at the same time, I is their greatest common divisor. If it is not equal to 0, i- 1, continue to divide A by I and B by I until the remainder is 0 at the same time.
Maximum common divisor:
The greatest common factor, also known as the greatest common factor and the greatest common factor, refers to the largest divisor of two or more integers. The greatest common divisor of a and b is (a, b). Similarly, the greatest common divisor of a, b and c is (a, b, c), and the greatest common divisor of multiple integers has the same symbol.
As early as around 300 BC, Euclid gave an efficient solution-division in his book Elements of Geometry. The principle used in division is very clever and simple. Suppose f(x, y) is used to represent the greatest common divisor of x and y, and k=x/y, b? =x%y, then x=ky+? B, if a number can divide x and y at the same time, it must divide b and y at the same time.
Numbers that can be divisible by B and Y at the same time will also be divisible by X and Y, that is, the common divisor of X and Y is the same as that of B and Y, and its greatest common divisor is the same, then f(x, y)=f(y, X% Y)(Y >;; 0), so that the original problem can be transformed into finding the greatest common divisor of two smaller fractions until one of them is 0, and the remaining number is the greatest common divisor of both.