Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Given $x, y, r \in \mathbb{Z}$, how can you tell whether there exist two integers $a$ and $b$ such that $ax + by = r$?

That is, how do you determine whether an integral linear combination exists for $x$, $y$, and $r$?

share|improve this question
    
Extended Euclidean algorithm? –  Ganesh Oct 21 '12 at 2:26

1 Answer 1

up vote 2 down vote accepted

Consider $d = \gcd(x, y)$.

$$\textrm{Then} \; \frac{ax + by}{d} =\frac{r}{d}, \frac{ax + by}{d} \in \mathbb{Z}$$

If $d$ does not divide $r$, there exist no possible $a, b \in \mathbb{Z}$. If $d$ divides $r$, the solution can be found by the Extended Euclidean Algorithm. Thanks to Ganesh for pointing me in the right direction.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.