# How many solutions for the equation $Y_1 + Y_2 + Y_3 + Y_4 + Y_5 = 6$? [duplicate]

How many solutions for the equation $Y_1 + Y_2 + Y_3 + Y_4 + Y_5 = 6$ ?

where $0\leq Y_1 \leq 3$ and $1\leq Y_2 \leq3$ and $Y_3,Y_4,Y_5\geq 0$ and $Y1,Y2,Y3,Y4,Y5$ are integers.

I tried to apply brute force and got following equations :

• $Y3 + Y4 + Y5 = 5\quad$ has $21$ Solutions
• $Y3 + Y4 + Y5 = 4\quad$ has $15$ Solutions
• $Y3 + Y4 + Y5 = 3\quad$ has $10$ Solutions
• $Y3 + Y4 + Y5 = 2\quad$ has $6$ Solutions
• $Y3 + Y4 + Y5 = 1\quad$ has $3$ Solutions
• $Y3 + Y4 + Y5 = 0\quad$ has $1$ Solution

Am I going right here ?

EDIT: Using generating functions gives $106$, but what is the error in above method.

## marked as duplicate by Jon Garrick, Community♦Jan 15 '17 at 5:29

• What you have noticed is that the number of ways to sum three numbers to make $n$ is $T_{n+1},$ the $(n+1)$st triangular number, which is $\frac 12(n+1)(n+2)$ – Ross Millikan Jan 15 '17 at 5:24