$a,b\in\mathbb{N}$. How many points with integers coordinates exist between $(a,0)$ and $(0,b)$? 
Let be $a,b\in\mathbb{N}$. Then, how many points with integers coordinates exist in the line segment created by $(a,0)$ and $(0,b)$?

I've already draw some expamples, but I can't find the relation between all of them. Probably something related to diophantine equations, divisibility, Euclides or something similar because these are the subjects we are studying  right now.
Any help will be appreciated.
 A: Write out the parametric equation of the segment in the complex plane:
$$s_{a,b}(t) = at + ib(1-t) .$$
Obviously, $t=0$ and $t=1$ always lead to a Gaussian integer (a complex number with integer components), so we need to find conditions under which some $t\in(0,1)$ leads to a Gaussian integer as well.
Hints: What happens when $\gcd\{a,b\}=1$? What happens when $\gcd\{a,b\}\neq 1$?
Bonus points: how many Gaussian integers are there on $s_{a,b}$ when $\gcd\{a,b\} = n$?
A: Excluding the possibility that $a = 0 = b$, the following three cases arise according to whether $a = 0$, $b=0$, or $a \neq 0 \neq b$. 
Case 1. If $a = 0 \neq b$, then the straight line through the points $(0, 0) and (0, b)$ has the equation $$ x = 0. $$
As a set this straight line can be represented by
$$
\left\{ (x, y) \in \mathbb{R}^2 \colon x=0 \right\}.
$$
Thus there are exactly $1+ \lvert b \rvert$ points with integer coordinates on the line segment joining the points $(0, 0)$ and $(0, b)$.
Case 2. If $b = 0 \neq a$, then the straight line through the points $(a, 0)$ and $(0, 0)$ has the equation
$$ y = 0. $$
As a set this straight line can be represented by
$$
\left\{ (x, y) \in \mathbb{R}^2 \colon y=0 \right\}.
$$
Thus there are exactly $1+ \lvert a \rvert$ points with integer coordinates on the line segment joining the points $(0, 0)$ and $(a, 0)$.
Case 3. If $a \neq 0 \neq b$, then the straight line through the points $(a, 0)$ and $(0, b)$ has the equation
$$
y = \frac{b - 0}{ 0-a} ( x-a)
$$
or 
$$
y = -\frac{b}{a}(x-a).
$$
As a set this straight line can be represented by
$$
\left\{ \, (x, y) \in \mathbb{R}^2 \, \colon \, y = -\frac{b}{a}(x-a) \, \right\}.
$$
Thus the number of integer points on the line segment joining the points $(0, b)$ and $(a, 0)$ is equal to the number of integer values $x$ in the interval between $0$ and $a$ for which $-\frac{b}{a}(x-a)$ is an integer. Let $d \colon= \mathrm{gcd}(a, b)$. Then $a/d$ and $b/d$ are both integers such that 
$$ \mathrm{gcd} \left( \frac{a}{d}, \frac{b}{d} \right) = 1. $$
And then 
$$
-\frac{b}{a}(x-a) = \frac{ b/d}{ a/d} (a-x),
$$
which is an integer if and only if $a/d$ divides $a-x$, which is the case if and only if $a/d$ divides $x$ because $a/d$ always $a$, and the values of $x$ in the interval between $0$ and $a$ for which $a/d$ divides $a-x$ are 
$$
x = 0, \frac{a}{d}, \frac{2a}{d}, \ldots, \frac{ (d-1) a }{d}, \frac{ d a}{d} = a,
$$
and thus there are $(d+1)$ such points in total.
Hope this helps.
