Euclidean algorithm (turning phase division)

Euclidean algorithm: GCD (a, b) = GCD (B, R), where r = a mod B

 

How to understand this algorithm is correct.

Set D1For any common divisor of a and B, that is d1|a,d1|b ,Because r = a mod B, D can be obtained.1|r

Therefore, any common divisor of a and B is also the common divisor of B and R, that is, the common divisor sets of them are the same.

So GCD (a, b) = GCD (B, a%b).

Leave a Reply

Your email address will not be published. Required fields are marked *