Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to show that there exist non-negative integers $x,y$ such that

$ax+by=ab+k$ where $a,b$ are co-prime whole numbers is true for all non zero integers $k$.

PS: Sorry for missing the key information that $a$ and $b$ are coprimes...

share|cite|improve this question

This is false as stated, since $\rm\,a,b,x,y\in \Bbb N\Rightarrow ax+by \ge 0,\,$ but $\rm\,ab+k < 0\, $ if $\rm\,k < -ab.\:$ Probably you meant: if $\rm\,a,b\in\Bbb N$ are coprime then $\rm\:ax+by = n > ab\!-\!a\!-\!b\,$ has a solution $\rm\,x,y\in \mathbb N.\:$

Indeed, by Bezout there are $\rm\,j,k \in \Bbb Z\:$ with $\rm\,aj+bk = 1,\:$ so scaling by $\rm\,n\,$ there are $\rm\,x,y \in \Bbb Z\,$ with $\rm\,ax+by = n.\:$ Since $\rm\,ax+by = a(x\pm b) + b(y\mp a)\,$ we can repeatedly add/subtract $\rm\,b\,$ from $\rm\,x\,$ till we get a solution with $\rm\,0\le x \le b\!-\!1.\:$ Then, necessarily, $\rm\,y\ge 0,\:$ since otherwise $\rm\:y\le -1\:$ so then $\rm\:n = ax+by \le a(b\!-\!1)+b(-1) \le ab-a-b,\:$ contra hypothesis. Thus $\rm\,x,y\ge 0,\,$ as claimed.

For a more geometrical viewpoint see here, whihc also includes links to the literature (Frobenius and postage stamp or coin chnaging problems).

share|cite|improve this answer

This is not true in general, e.g $2x+2y=4+1$. It is true only if $k$ is a multiple of the $\gcd(a,b)$.

share|cite|improve this answer


  • Two integers $a,b$ are coprime iff $ac+bd=1$ for some $c,d\in\mathbb Z$ (see this).
  • For coprime $a,b$ and any $n\in\mathbb Z$ the equation $ax+by=n$ has a solution ($x=cn$...).
  • If $ax+by=n$ then $\forall z\in\mathbb N, \ \ \ a(x-bz)+b(y+az)=a(x+bz)+b(y-az)=n.$
  • If $ax+by=n$ and $x>0,y<0$ (the same when $x<0,y>0$) then $\exists z\in\mathbb N:$ $x-bz>0, \ y+az>0 \iff \exists z\in\mathbb N: -\dfrac{y}{a}<z<\dfrac xb \iff \dfrac xb + \dfrac{y}{a}>1 \iff ...n> ab.$
share|cite|improve this answer
But the OP seeks nonnegative solutions. – Math Gems Jan 23 '13 at 23:56
@MathGems: Right, thanks. – P.. Jan 24 '13 at 6:10

Your Answer


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.