Number of solutions pairs of $ax+by=n$ 
Question: Given that $a, b, n$ are positive integers and $x, y$ are nonnegative integers such that 
  $$ax+by=n$$
  has at least one solution pair $(x, y) $.
  How many solution pairs $(x, y) $ are there?

For example,
$$2x+3y=12$$
has $3$ solution pairs. They are
$$(3,2),(6,0), (0,4).$$
However, I have no idea on how to find a general formula. 
 A: Let $ (x_0,y_0) $ be a solution of $ ax+by = n $, then by some elementary number theory, all the integer solution is given by 
$$ x=x_0+\frac{b}{(a,b)}t,y = y_0-\frac{a}{(a,b)}t $$
where $ (a,b) $ is the greatest common divider and $ t $ is any integer.
Thus it suffices to let
$$ -\frac{(a,b)x_0}{b}\leq t\leq \frac{(a,b)y_0}{a}. $$
Because $ -\frac{(a,b)x_0}{b} $ and $ \frac{(a,b)y_0}{a} $ may fail to be integers, there does not exist a analytical formula.
But the number of the solutions is approximately $\frac{n(a,b)}{ab}$, because $\frac{x_0}{b}+\frac{y_0}{a}=\frac{n}{ab}$.
A: If GCD od $a$ and $b$ is 1.
Let the pairs of integers  $(x_0,y_0)$, be the first solution of $ax+by=n~(*)$. Then
Let $x=x_0+bm, y=y_0-am$ are the possible solutions. Since both $x,y \ge 0$
you can easily find the possible values of $m$ and hence the number of solutions.
The number of solutions of this Eq (*). are $N=[\frac{n}{ab}]$ where $[.]$ means integer part. Also, $N$ may be one more than this if the remainder($r$) when $n$ is divided by $ab$  satisfies the relation $ax+by=r$ one pair of non-negative integers $x$ and $y$.
A: 
Theorem
Suppose diophanitine equation $ax+by=c$ has solution $\{x_0,y_0\}\subset\mathbb{Z}$
$$\text{And } d:=\gcd(a,b)\mid c$$
$$\text{Then }\forall m\in\mathbb{Z},s.t.\{x_0+m\cdot\frac{b}{d},y_0-m\cdot\frac{a}{d}\}\subset\mathbb{Z}\text{ are all the solutions}$$
Proof.
By assumption that $\{x_0,y_0\}$ is a solution since
$$a(x_0+m\frac{b}{d})+b(y_0-m\frac{a}{d})$$
$$=ax_0+m\frac{ab}{d}+by_0-m\frac{ab}{d}$$
$$=ax_0+by_0=c$$
This proved they are indeed solutions for $ax+by=c$
And the rest is just to show they are the only solutions $\dots$

This proof can be found in
"UTM-A Readable Introduction to Real Mathematics-Chapter $7$-Theorem $7.2.10$."
