Given $$A+2B+3C=N $$ where $N$ is a given positive integer.
$A ,B,C\in\mathbb{N}$ vary from $0$ to $\infty$.
How many solutions will be there to this equation?
Given $$A+2B+3C=N $$ where $N$ is a given positive integer.
$A ,B,C\in\mathbb{N}$ vary from $0$ to $\infty$.
How many solutions will be there to this equation?
On
It appears to be sequence A001399 at the Online Encyclopedia of Integer Sequences, where the simple formula $${\rm round}{(n+3)^2\over12}$$ is given, along with lots of interpretations, links, references, and so on.
Let $X=C, Y=B+C, Z=A+B+C$, then this is equivalent to finding the number of non-negative integer solutions to $X+Y+Z=N$ s.t. $X \leq Y \leq Z$.
First ignore the restriction on $X, Y, Z$. In total we have $\binom{N+2}{2}$ solutions.
The number of solutions with $Y=Z$ is just the number of non-negative integer solutions to $2Y \leq N$, giving $\lfloor \frac{N}{2} \rfloor+1$. By symmetry we get the same number of solutions for $X=Y, X=Z$.
The number of solutions for $X=Y=Z$ is 1 if $3 \mid N$ and 0 otherwise. We can represent this as $1-\lceil \frac{N}{3}-\lfloor \frac{N}{3} \rfloor \rceil$.
The number of solutions with exactly 2 variables equal is thus $3[(\lfloor \frac{N}{2} \rfloor+1)-(1-\lceil \frac{N}{3}-\lfloor \frac{N}{3} \rfloor \rceil)]$.
Now going back to the problem, each solution where $X<Y<Z$ corresponds to 6 solutions where $X, Y, Z$ are distinct. Each solution with $X \leq Y \leq Z$ and exactly 2 of them equal corresponds to 3 solutions where exactly 2 of them equal but without the condition $X \leq Y \leq Z$.
We thus get:
\begin{align} & \frac{\binom{N+2}{2}-3(\lfloor \frac{N}{2} \rfloor+1)+2(1-\lceil \frac{N}{3}-\lfloor \frac{N}{3} \rfloor \rceil)}{6} \\ & +\frac{3(\lfloor \frac{N}{2} \rfloor+1)-3(1-\lceil \frac{N}{3}-\lfloor \frac{N}{3} \rfloor \rceil)}{3} +(1-\lceil \frac{N}{3}-\lfloor \frac{N}{3} \rfloor \rceil) \\ & =\frac{\binom{N+2}{2}+3(\lfloor \frac{N}{2} \rfloor+1)+2(1-\lceil \frac{N}{3}-\lfloor \frac{N}{3} \rfloor \rceil)}{6} \end{align}