Now, we know the equation

ax+by=gcd(a,b)

There is always an integer solutionxAndyHow many solutions are there and how to express them?

We are mutually exclusiveaAndbLet gogcd(a,b)=1, assuming(x_1,y_1)It’s an equationax+by=1A solution of. adoptx_1subtractbSum of multiples ofy_1addaOther solutions can be obtained. In other words, for any integerkWe get a new solution(x_1+kb,y_1-ka)By calculating

a(x_1+kb)+b(y_1-ka)=ax_1+akb+by_1-bka=ax_1+by_1=1

Still observinggcd(a,b)=1It can be proved that this method gives all solutions and hypotheses(x_1,y_1)And(x_2,y_2)It’s an equationax+by=1Two solutions of, namely

Ax_ 1+by_ 1 = 1 and ax_ 2+by_ 2=1

We use ity_1Multiply the first equation with they_2Multiply the second equation and subtract itbAfter sorting outax_1y_2-ax_2y_1=y_2-y_1

Similar, if you usex_2Multiply the first equation with thex_1Multiply the second equation and subtract itbx_2y_1-bx_1y_2=x_2-x_1

Ifk=x_2y_1-x_1y_2, then we get

x_2=x_1+kb\\

y_2=y_1-ka

Therefore, from the initial understanding of the solution(x_1,y_1)By going to differentkValue can be obtainedax+by=1Every solution of(x_1+kb,y_1-ka)

Ifgcd(a,,b)>1What will happen?

We orderg=gcd(a,b)The equation is known by Euclidean algorithmax+by=gAt least one solution(x_1,y_1), andgto be divisible byaAndbSo(x_1,y_1)It’s a simple equation

\frac{a}{g}x+\frac{b}{g}y=1

The solution. Through thekThe value of

(x_1+k·\frac{b}{g},y_1-k \frac{a}{g})

###Theorem of linear equation

set upaAndbIs a nonzero integer,g=gcd(a,b), equationax+by=gThere is always an integer solution(x_1,y_1)Then each solution of the equation can be obtained by the Euclidean algorithm(x_1+k·\frac{b}{g},y_1-k \frac{a}{g})Get, wherekCan be any integer.

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