<s>[INST] Counting integral solutions Suppose $a + b + c = 15$
Using stars and bars method, number of non-negative integral solutions for the above equation can be found out as $15+3-1\choose15$ $ =$ $17\choose15$
How to extend this principle for finding number of positive integral solutions of
$a + b + 3c = 15$?
I tried to do it by substituting $3c$ with another variable $d$. But could not succeed.
 [/INST] One way to solve this is using generating functions. If you multiply $A(z) = \sum_{n \ge 0} a_n z^n$ by $B(z) = \sum_{n \ge 0} b_n z^n$, you get:
$$
A(z) \cdot B(z) 
  = \sum_{n \ge 0} \left(\sum_{0 \le k \le n} a_k b_{n - k}\right) z^n
$$
If $a_n$ is the number of ways of picking $a$ to have value $n$, and similarly for $b$, the coefficient of $z^n$ is the number of combining a value of $a$ and one of $b$ to make up $n$.
For your original example, there is $1$ way to get $a$ (and $b$, $c$) of any particular value, so that:
$$
A(z) = B(z) = C(z)
  = \sum_{n \ge 0} z^n
  = \frac{1}{1 - z}
$$
so that the number of ways to get $n$ is ($[z^n]$ is just shorthand for "get the coefficient of $z^n$"):
$$
[z^n] A(z) \cdot B(z) \cdot C(z)
   = [z^n] \frac{1}{(1 - z)^3}
   = (-1)^n \binom{-3}{n}
   = \binom{n + 3 - 1}{3 - 1}
   = \binom{n + 2}{2}
$$
For the second case you have:
$$
C(z) = 1 + z^3 + z^6 + \dotsb
     = \sum_{n \ge 0} z^{3 n}
     = \frac{1}{1 - z^3}
$$
so here you need:
$\begin{align}
A(z) \cdot B(z) \cdot C(z)
  &= \frac{1}{(1 - z)^2 (1 - z^3)} \\
  &= \frac{1 + 2 z}{9 (1 + z + z^2)}
       + \frac{2}{9 (1 - z)}
       + \frac{1}{3 (1 - z)^2}
       + \frac{1}{3 (1 - z)^3}
\end{align}$
This is just the partial fractions mostly used when integrating.
The first term is troublesome as written. Using complex numbers you can write it as:
$$
\frac{1 + 2 z}{1 + z + z^2}
  = - \frac{\omega}{1 - \omega z}
        - \frac{\omega^2}{1 - \omega^2 z}
$$
Here $\omega = - 1/2 + \mathrm{i} \sqrt{3} /2$ is a cube root of $1$, and $\omega^2 = \overline{\omega}$ is just it's conjugate. As the sum of a complex number and it's conjugate is just twice their real part, this term contributes:
$$
- \omega \cdot \omega^n - \overline{\omega} \cdot \overline{\omega}^n
  = - \omega^{n + 1} - \overline{\omega}^{n + 1}
  = - 2 \Re \left( \omega^{n + 1} \right)
$$
We can write:
$$
\omega = \exp \left( \frac{2 \pi \mathrm{i}}{3} \right)
$$
so that:
$$
\omega^{n + 1}
  = \exp \left( \frac{2 \pi (n + 1) \mathrm{i}}{3} \right)
  = \cos \left( \frac{2 \pi (n + 1)}{3} \right)
      + \mathrm{i} \sin \left( \frac{2 \pi (n + 1)}{3} \right)
$$
and finally the contribution is:
$$
- 2 \Re \left( \omega^{n + 1} \right)
  = - 2 \cos \left( \frac{2 \pi (n + 1)}{3} \right)
$$
Adding the contributions of the other terms gives:
$$
\frac{2}{9} 
  + \frac{1}{3} \binom{n + 2 - 1}{2 - 1} 
  + \frac{1}{3} \binom{n + 3 - 1}{3 - 1}
  - \frac{2}{9} \cos \left( \frac{2 \pi (n + 1)}{3} \right)
  = \\
    \frac{3 n^2  + 15 n + 16}{18} 
      - \frac{2}{9} \cos \left( \frac{2 \pi (n + 1)}{3} \right)
$$
The last expression looks quite weird, but you'll notice that it repeats with period $3$, so you could write this out as three cases depending on the remainder when $n$ is divided by $3$.
OK, back to your specific case now. You asked for a sum of $15$. The number of ways of getting that one is:
$$
\frac{3 \cdot 15^2  + 15 \cdot 15 + 16}{18} 
      - \frac{2}{9} \cos \left( \frac{2 \pi (15 + 1)}{3} \right)
  = 51
$$
</s>