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

Suppose that some nonzero integer $x$ is $x = pa + qb$ where $p, q, a, b$ are also nonzaero integers.

What would be the easy way to find another decomposition of $x$ into following: $x = ra + sb$ where $a, b$ are the equal $a, b$ in the previous case and $r and s$ are free to be set (= are not fixed numbers)?

share|cite|improve this question
up vote 0 down vote accepted

Plug in the new translated integers

$p\rightarrow p+d_1$

$q\rightarrow q+d_2$

to get

$x=(p+d_1)a+(q+d_2)b=x+(d_1 a+d_2 b),$

i.e. you want to solve

$d_1 a+d_2 b=0,$

and so

$d_1=b\ n$

$d_2=-a\ n$

for some $n$, which you choose to make every number in the system an integer.

share|cite|improve this answer

Let $d$ be the gcd of $a$ and $b$, let $a=da'$, $b=db'$. Use $$r=p+tb', \qquad s=q-ta',$$ where $t$ is any integer.

share|cite|improve this answer

If $x = p a + q b$ and also $x = r a + s b$, then $(r - p) a = (q - s) b$. You could take $r = p + k b$ and $s = q - k a$ for any integer $k$ (and these will be all the possibilities if $\gcd(a,b) = 1$).

share|cite|improve this answer

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.