# 1 equation, 2 unknowns, need integer solution

1. Sep 10, 2011

### Fellowroot

1. The problem statement, all variables and given/known data

I needed to solve this single equation with two unknowns.

199x - 98y = -5

0< x <=99
0< y <=99

I typed the equation into Wolfram Alpha and got an integer solution of:

x = 98n + 31
y = 199n +63 when n is an integer

Since I know my restriction on x and y I can conclude that my solution is:

x = 31
y = 63 when n = 0

My question is, how do I obtain that integer solution that Wolfram Alpha gave me?

[edit, changed the + to a - sign from an error Ray Vickson pointed out, thanks.]

Last edited: Sep 10, 2011
2. Sep 10, 2011

### Ray Vickson

There is something wrong with your question. If x and y are integers >= 1, then 199x + 98y is >= 207, so can't be equal to -5.

RGV

3. Sep 10, 2011

### Fellowroot

Sorry, it was supposed to be:

199x - 98y = -5

4. Sep 11, 2011

### ArcanaNoir

How about solving for y and then graphing it, and looking for where the line crosses two integers?

5. Sep 11, 2011

### phyzguy

These are called Diophantine equations:
http://en.wikipedia.org/wiki/Diophantine_equation#Linear_Diophantine_equations
I don't think there is a general method for finding solutions - with relatively small numbers like this, the quickest way is to simply exhaustively search through the allowed integers and see if there are any solutions.

6. Sep 11, 2011

### awkward

Since the GCD of 99 and 198 is 1, there are integers x and y such that

99 x + 198 y = 1

You can find x and y by several methods, such as the Extended Euclidean Algorithm

http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm

Then 99 (-5x) + 198 (-5y) = -5

That gives you one solution, not necessarily in the acceptable range, but maybe you can use that to find others.

7. Sep 12, 2011

### icystrike

Its a common linear diophantine equation. Go search for it :)