Given an equation of a straight line of form $Ax + By = C$. where $A,B,C$ are integers. How could we check if this passes through any lattice point or not?
Please suggest me a suitable algorithm.
Given an equation of a straight line of form $Ax + By = C$. where $A,B,C$ are integers. How could we check if this passes through any lattice point or not?
Please suggest me a suitable algorithm.
On
I assume the lattice you are using is $\mathbb{Z}^2$, consisting of all integer pairs $(x,y)$. What you have is an example of a linear diophantine equation, meaning that you are looking for integer pairs $(x,y)$ satisfying this equation. The key here is to see whether or not $C$ is divisible by $gcd(A,B)$. If so, there are infinitely many solutions (this is known as Bezout's identity).
Assuming you mean the lattice of integers, that is equivalent to checking if the equation has integer solutions.
Assume that $k\times GCD(A,B)=C$. Then by Euclid's algorithm, there are $X,Y$ such that $AX+BY=GCD(A,B)$, so $AkX+BkY=C$, where $kX$ and $kY$ must be integers.
On the other hand, assume $Ax+By=C$ has a solution. Then $GCD(A,B)\left(\frac{A}{GCD(A,B)}X+\frac{B}{GCD(A,B)}Y\right)=C$ so $GCD(A,B)$ divides $C$.