# Does $Ax + By = C$ pass through any lattice point?

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.

-
What is the lattice? – Fabian Apr 10 '11 at 19:13
Assuming you mean the integer lattice in $\mathbb{R}^2$, it might be instructive to consider Euclid's Algorithm, since there are always integer solutions to the equation $Ax+By=GCD(A,B)$. So if $GCD(A,B)\vert C$ then you definitely have integer solutions. I'm not sure about the converse, i.e. if GCD isn't a factor. – Jon Beardsley Apr 10 '11 at 19:19
i assume $\mathbb{Z}^2$. $Ax+By=C$ has solutions iff $(A,B)|C$ ($C$ would have to be in the ideal generated by $A,B$) – yoyo Apr 10 '11 at 19:19
@JBeardz Your argument is an if and only if statement. – Adrián Barquero Apr 10 '11 at 19:22

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$.
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).