Chapter 6: linear equations and the greatest common factor (1)


Theorem of linear equation

Likeax+byThe smallest positive integer of is equal togcd(a,b)

We use Euclidean algorithm to construct the appropriatexAndyIn other words, the equation will be describedax + by= gcd(a,b)Integer solutionxAndyMethods. Because of each numberax+bycovergcd(a,b)to be divisible by,ax + byThe smallest positive integer value of is exactlygcd(a,b)

Solving equations by Euclidean algorithmax+by=gcd(a,b)

For example, try to solve the problem22x+60y=gcd(22,60)

In the first step, Euclidean algorithm is used to calculate the greatest common factor

60 = 2·22 +16
22 = 1·16 +6

This shows thatgcd(22,60)=2This is an obvious fact that there is no need for Euclidean algorithm. However, it is very important to use Euclidean algorithm because we use the middle quotient and remainder to solve the equation. First, rewrite the first equation into

16 = a-2b, where a = 60, B = 22

Next, replace the value in the second equation with this value16, get


Rearrange the equation6Move to one side


Now the value of16And6Put in the next equation16=2·6+4


The result of transfer


Finally, use the equation6=1·4+2have to


Rearrange the equation to get the desired solution


This work adoptsCC agreementThe author and the link to this article must be indicated in the reprint


Recommended Today

Python SSL certificate verification solution

This article mainly introduces the solution of Python SSL certificate verification problem, which is introduced in great detail through the example code. It has a certain reference learning value for everyone’s study or work, and friends who need it can refer to it 1、 SSL issues 1. When you don’t enable fiddler, the Python code […]