1

I have read this nice post:

How to find solutions of linear Diophantine ax + by = c?

and it all makes sense, but was wondering if one can apply this only if $a > 0, b > 0, c > 0$?

Consider for example:

$ 13x - 23y = -4 $

$ Gcd(13,23) = 1 $ so I'm not sure there is straight applicability of the method derived in the post mentioned above. However, this equation has clearly solutions, i.e., (for $x=5,y=3$):

$ 13 * 5 - 23 * 3 = 65 - 69 = -4 $.

So how to tackle such equations if we have $gcd(a,b) = 1$ ?

1 Answers1

1

Solve $13x+23y=4$ and adjust the signs of $x$ and $y$.

Using the algorithm described in this answer $$ \begin{array}{r} &&1&1&3&3\\\hline 1&0&1&-1&4&-13\\ 0&1&-1&2&-7&23\\ 23&13&10&3&1&0 \end{array} $$ we get the answer $$ 13(-7)+23(4)=1 $$ multiply by $4$ $$ 13(-28)+23(16)=4 $$ add $13(23)+23(-13)=0$ $$ \bbox[5px,border:2px solid #C0A000]{13(-5)+23(3)=4} $$ changing signs gives $$ \bbox[5px,border:2px solid #C0A000]{13(5)-23(3)=-4} $$

robjohn
  • 345,667