Let $\mathbb{N} := \{0, 1, 2, ...\}$ be the set of natural numbers (i.e nonnegative integers). Given $N\in\mathbb{N}\backslash\{0\}$, $n\in\mathbb{N}$, and $(a_1, a_2, ..., a_N) \in\mathbb{N}^N$, let $P_{N}(a_1, a_2, ..., a_N, n)$ be the number of solutions to the linear Diophatine equation \begin{equation} \sum_{k=1}^N{a_kx_k} = n, \space x\in\mathbb{N}^N \end{equation}
Note that $P_{N}$ defines a function from $\mathbb{N}^{N+1}$ to $\mathbb{N}\backslash\{0\}$.
Then, the following recursive formula is easily established by induction on $N$ (for $N>2$, fix $x_1\in[0, n/a_1]\cap \mathbb{N}$, and solve for $(x_2$, ..., $x_N)\in\mathbb{N}^{N-1}$) \begin{equation} \begin{split} P_1(a_1, n) = 1, \text{if $n$ is a multiple of $a_1$, $0$ otherwise;}\\ P_N(a_1, a_2, ..., a_N, n) = \sum_{x_1\in [0, n/a_1]\cap \mathbb{N}}P_{N-1}(a_2, ..., a_N, n - x_1a_1)\text{, if $N>1$} \end{split} \end{equation}
The following (naive) code snippet in Python will solve any instance of the problem in finite time.
def diophantine_count(a, n): """Computes the number of nonnegative solutions (x) of the linear Diophantine equation a[0] * x[0] + ... a[N-1] * x[N-1] = n Theory: For natural numbers a[0], a[2], ..., a[N - 1], n, and j, let p(a, n, j) be the number of nonnegative solutions. Then one has: p(a, m, j) = sum p(a[1:], m - k * a[0], j - 1), where the sum is taken over 0 <= k <= floor(m // a[0]) Examples -------- >>> diophantine_count([3, 2, 1, 1], 47) 3572 >>> diophantine_count([3, 2, 1, 1], 40) 2282 """ def p(a, m, j): if j == 0: return int(m == 0) else: return sum([p(a[1:], m - k * a[0], j - 1) for k in xrange(1 + m // a[0])]) return p(a, n, len(a))
Now that we have the hammer, let's find the nails...
OK, returning to your problem, we have $P_3(3, 2, 1, 1, 47) = 3572$.
N.B: $P_3(3, 2, 1, 1, 40) = 2282$, in accordance with mercio's brute-force computation :)
Cheers,