# How to solve a linear equation 'mx - ny = 0' with two unknowns such that I get strictly integer solution?

Problem Statement
I have a linear equation of the form $$m*x - n*y = 0$$, where $$m, n$$ are known rational numbers (integers, terminating decimals, and repeating decimals). How to find the values of $$x, y$$ that solves the above equation such that they are strictly integers.

Research Effort
If $$m = 10, n = 2$$, then it is very easy to find $$x, y$$ whose values will be 1 & 5 respectively. But I don't know how to solve this equation for large numbers, fractional numbers. I used matlab to write a small code to find this using trial & error

length = 100;
m = 1440;
n = 115.2;
x = 1:1:length;
mx = m*x;
y = mx/n;


Then i look through y array to find the first integer number & that becomes my solution. But how do i do solve it mathematically without this matlab trial & error

• Multiply by the $\operatorname{lcm}$ of the denominators of $\,m,n\,$ and you get an equation in integers. Then it's obvious. – dxiv Sep 29 '18 at 5:29

This is a question at the very beginning of Linear Algebra. Several cases have to be considered. 1) $$n=0$$ and $$m=0$$. Then the equation is satisfied for all $$x,y$$. 2) If $$n\not=0$$ you may choose $$x$$ arbitrarily and calculate $$y$$ from the equation as $$y=\frac{mx} n$$.
The remaining case $$n=0$$ and $$m\not=0$$ is treated similarily.
Edit according to modified question: We may assume that both $$m$$ and $$n$$ are integer s by multiplying the the equation with some suitable integer. Then in the first case above $$x,y$$ are arbitrary integers. In the second case $$x$$ is arbitrary up to the condition that $$n$$ must be a divisor of $$mx$$. The Thier case again is of a similar taste.
• If $m,n$ are rational, there are integers $a,b,c,d$ such that $m=a/b,n=c/d$ (and $b,d\not=0$). Then you may multiply the original equation with $bd$ to get the equation $(mab)x-(nab)y=0$ with integer coefficients $mab$ and $nab$. Another tag would be diophantine equation. You also may look at Wikipedia, or so, with both tags. – Jens Schwaiger Sep 29 '18 at 6:08