Positive solutions extended euclid algorithm

1.1k Views Asked by At

Given coprime $a,b$ and $n\in\Bbb N$, is there a simple criterion to find if there is no positive integer solution to $$ax+by=n?$$

1

There are 1 best solutions below

2
On

If $\gcd(a,b)=1$, by the extended euclidean algorithm there is for sure a solution $(x_0,y_0)$ of $ax+by=1$, hence an infinite number of solutions, given by $(x_0-kb,y_0+ka)$ for any $k\in\mathbb{Z}$.

That gives that $(nx_0-nkb,ny_0+nka)$ is an integer solution of $ax+by=n$.

However, a non-negative solution is granted to exist only if $\color{red}{n\geq (a-1)(b-1)}$. I think that is pretty well-known. If we take $A=\{0,a,2a,\ldots\}$ and $B=\{0,b,2b,\ldots\}$, we have that $ \left|\{1,ab-a-b\}\cap(A+B)\right|$ is the number of lattice points in a triangle, hence about half the integers in the range $[1,ab-a-b]$ cannot be represented as a linear combination of $a$ and $b$ with non-negative integer coefficients.