Number of integer solutions to $Ax + By + Cz = D$ How many integer solutions exits for the equations, $Ax + By + Cz = D$, where 
$B = (A + 1), C = (A + 2)$, and $x, y, z$ are non-negative i.e $x, y, z, >= 0$
I require a general solution which can be implemented using code as well. We would be given the values of $A, D$.
 A: So, assuming that $A,\, D$ are non negative integers
$$
\left\{ \matrix{
  0 \le x,y,z,A,D\; \in \mathbb Z \hfill \cr 
  Ax + \left( {A + 1} \right)y + \left( {A + 2} \right)z = D \hfill \cr}  \right.
$$
when $A=0$ we are left with $y+2z=D$ and it is easy to see that the number of solutions is
$$
N_{A = 0}  = 1 + \left\lfloor {{D \over 2}} \right\rfloor  = \left\lceil {{{D + 1} \over 2}} \right\rceil 
$$
Taking then $1 \le A$, we can write
$$
\left\{ \matrix{
  0 \le x,y,k,A,D \hfill \cr 
  Ax + \left( {A + 1} \right)y = D - \left( {A + 2} \right)k \hfill \cr}  \right.
$$
and since $\gcd \left( {A,A + 1} \right) = 1$ we can apply to the Popoviciu's Theorem which reads
$$ \bbox[lightyellow] {  
\eqalign{
  & p_{\left\{ {a,b} \right\}} (n) = \left| {\,\left\{ \matrix{
  0 \le x,y,a,b,n \in Z \hfill \cr 
  \gcd (a,b) = 1 \hfill \cr 
  ax + by = n \hfill \cr}  \right.\;} \right| =   \cr 
  &  = {n \over {ab}} - \left\{ {{{b^{\,\left( { - 1} \right)} n} \over a}} \right\} - \left\{ {{{a^{\,\left( { - 1} \right)} n} \over b}} \right\} + 1 \cr} 
} \tag{1}$$
where:
$\left\{ x \right\} $ denotes the fractional part : $\left\{ x \right\} = x - \left\lfloor x \right\rfloor $
and the exponent in brackets denotes the modular inverse
$$
b^{\,\left( { - 1} \right)} b \equiv 1\;\left( {\bmod a} \right)\quad a^{\,\left( { - 1} \right)} a \equiv 1\;\left( {\bmod b} \right)
$$
In this respect we have
$$
\eqalign{
  & A^{\,\left( { - 1} \right)} A \equiv 1\;\left( {\bmod A + 1} \right)\quad  \Rightarrow \quad A^{\,\left( { - 1} \right)}  = A  \cr 
  & \left( {A + 1} \right)^{\,\left( { - 1} \right)} \left( {A + 1} \right) \equiv 1\;\left( {\bmod A} \right)\quad  \Rightarrow
 \quad \left( {A + 1} \right)^{\,\left( { - 1} \right)}  = 1 \cr} 
$$
Therefore the Popoviciu's theorem gives
$$
N_{\,1 \le A}  = \sum\limits_{k = 0}^{\left\lfloor {D/\left( {A + 2} \right)} \right\rfloor } {\,\left( {{{D - \left( {A + 2} \right)k} \over {A\left( {A + 1} \right)}}
  - \left\{ {{{D - \left( {A + 2} \right)k} \over A}} \right\} - \left\{ {{{A\left( {D - \left( {A + 2} \right)k} \right)} \over {A + 1}}} \right\} + 1} \right)} 
$$
The terms above can be simplified to some extent. Let's put
$$d=\left\lfloor {D/\left( {A + 2} \right)} \right\rfloor $$
Then
$$
\eqalign{
  & \sum\limits_{k = 0}^d {{{D - \left( {A + 2} \right)k} \over {A\left( {A + 1} \right)}} + 1}
  = {{D + A\left( {A + 1} \right)} \over {A\left( {A + 1} \right)}}\left( {d + 1} \right) - {{\left( {A + 2} \right)} \over {A\left( {A + 1} \right)}}{{\left( {d + 1} \right)d} \over 2} =   \cr 
  &  = {{\left( {d + 1} \right)} \over {A\left( {A + 1} \right)}}\left( {D - d + A\left( {A - d/2 + 1} \right)} \right) \cr} 
$$
and
$$
\eqalign{
  & \left\{ {{{D - \left( {A + 2} \right)k} \over A}} \right\} + \left\{ {{{A\left( {D - \left( {A + 2} \right)k} \right)} \over {A + 1}}} \right\} =   \cr 
  &  = \left\{ {{{D - 2k} \over A}} \right\} + \left\{ {{{A\left( {D - k} \right)} \over {A + 1}}} \right\} \cr} 
$$
Finally we obtain
$$ \bbox[lightyellow] {  
\eqalign{
  & N_{\,1 \le A}  = {{\left( {d + 1} \right)} \over {A\left( {A + 1} \right)}}\left( {D - d + A\left( {A - d/2 + 1} \right)} \right) +   \cr 
  &  - \sum\limits_{k = 0}^d {\left\{ {{{D - 2k} \over A}} \right\} + \left\{ {{{A\left( {D - k} \right)} \over {A + 1}}} \right\}}  \cr} 
} \tag{2}$$
A: First note that $\gcd(A, A + 1, A + 2) = 1 $. Since this gcd while divide $D$ this Diophantine equation will always have solutions. So first solve $Au + (A+1)v = \gcd(A, A+1) = 1$. Then solve $(1)w + (A+2)s = gcd(1,A+2) = 1$. After finding the integer solutions(values of $u,v,w$ and $s$) using the Extended Euclidean Algorithm we then have
\begin{align}
w + (A +2)s &= 1\\
(Au + (A+1)v)w + (A+2)s &= 1\\
A(uw) + (A+1)(vw) + (A+2)s &= 1\\
A(Duw) + (A+1)(Dvw) + (A +2)(Ds) &= D
\end{align}
Thus we have our solutions $x = Duw$, $y = Dvw$ and $z = Ds$.
