Number of integer lattice points between two rational points I'm trying to find a way to compute the number of integer lattice points $\left ( (x, y) \in \mathbb{Z}^2 \right )$ between two rational points $\left ( (p, q) \in \mathbb{Q}^2 \right )$.
Let $(p_1, q_1)$ and $(p_2, q_2)$ denote the points in question. 
It's easy if both happen to be integer lattice points (which could happen since integers are also rationals,) you can use the method described in this math.stackexchange answer, which says it would be $\text{gcd}(q_2 - q_1, p_2 - p_1) + 1$ (including both endpoints.)
It's also straightforward if $q_1 = q_2$ (or $p_1 = p_2$). If $q_1 = q_2$ and $q_1 \notin \mathbb{Z}$, then it's zero. If $q_1 = q_2$ and $q_1 \in \mathbb{Z}$, then you basically cut off the ends of the segment until it's endpoints are integral. (i.e. if $p_1 < p_2$, consider the segment between $(\lceil p_1 \rceil, q_1)$ and $(\lfloor p_2 \rfloor, q_1)$, which would give you $\lfloor p_2 \rfloor - \lceil p_1 \rceil + 1$ points.)
But what if $(p_1, q_1), (p_2, q_2) \in \mathbb{Q}^2 \setminus \mathbb{Z}^2$ with $q_1 \neq q_2$ and $p_1 \neq p_2$?
Any help/advice would be much appreciated! Thank you!
 A: These are just a few thoughts, not a complete answer, but perhaps it helps.

The points between distinct points $(p_0,q_0),(p_1,q_1)\in\Bbb{Q}^2$ are the points of the form
$$(p_t,q_t):=t(p_1,q_1)+(1-t)(p_0,q_0),$$
with $t\in[0,1]$. Because $p_0,p_1,q_0,q_1\in\Bbb{Q}$, such a point is rational if and only if $t\in\Bbb{Q}$. The question is then for which rational numbers in the interval $[0,1]$ the two coordinates
$$p_t:=tp_1+(1-t)p_0
\qquad\text{ and }\qquad
q_t:=tq_1+(1-t)q_0,$$
are both integers. Let $a_i,b_i,c_i,d_i,r,s\in\Bbb{Z}$ be such that
$$p_i:=\frac{a_i}{b_i},\qquad q_i:=\frac{c_i}{d_i},\qquad t:=\frac{r}{s},$$
and all fractions are in reduced form with positive denominators. Then
$$p_t=\frac{a_1b_0r+a_0b_1(s-r)}{b_0b_1s}
\qquad\text{ and }\qquad
q_t=\frac{c_1d_0r+c_0d_1(s-r)}{d_0d_1s}.$$
In particular, because $r$ and $s$ are coprime, we see that $s$ must divide
$$a_1b_0-a_0b_1
\qquad\text{ and }\qquad
c_1d_0-c_0d_1.$$
This means $s$ is a positive divisor of
$$\gcd(a_1b_0-a_0b_1,c_1d_0-c_0d_1).$$
This already gives an upper bound on the number of integer points on the line.
Moreover, we see that $b_1$ must divide $b_0r$ and $d_1$ must divide $d_0r$. This means $r$ is a multiple of
$$\operatorname{lcm}\left(\frac{b_1}{\gcd(b_0,b_1)},\frac{d_1}{\gcd(d_0,d_1)}\right).$$
Finally, we see that $b_0$ must divide $b_1(s-r)$ and $d_0$ must divide $d_1(s-r)$, so $s-r$ is a multiple of
$$\operatorname{lcm}\left(\frac{b_0}{\gcd(b_0,b_1)},\frac{d_0}{\gcd(d_0,d_1)}\right).$$
