How many ordered quadruples of positive integers $\{a,b,c,d\}$ are there such that $a\leq b\leq c\leq d\leq 50$ and $a+b+c+d=100$?

In the following answer (which was slightly more cumbersome than I had expected) we use the coefficient of operator $[z^n]$ to denote the coefficient of $z^n$ in a series. This way we can formulate the problem as finding the coefficient of $z^{100}$ in the sum below and doing somewhat coefficient extraction. \begin{align*} [z^{100}]\sum_{1\leq a\leq b\leq c\leq d\leq 50}z^{a+b+c+d}\tag{1} \end{align*}

We obtain \begin{align*} \color{blue}{[z^{100}]}&\color{blue}{\sum_{1\leq a\leq b\leq c\leq d\leq 50}z^{a+b+c+d}}\\ &=[z^{100}]\sum_{a=1}^{50}\,\sum_{b=a}^{50}\,\sum_{c=b}^{50}\,\sum_{d=c}^{50}z^{a+b+c+d}\tag{2}\\ &=[z^{100}]\sum_{a=0}^{49}\,\sum_{b=0}^{49-a}\,\sum_{c=0}^{49-a-b}\,\sum_{d=0}^{49-a-b-c}z^{4a+3b+2c+d+4}\tag{3}\\ &=[z^{96}]\sum_{a=0}^{49}\,\sum_{b=0}^{49-a}\,\sum_{c=0}^{49-a-b}z^{4a+3b+2c}\,\frac{1-z^{50-a-b-c}}{1-z}\tag{4}\\ &=[z^{96}]\frac{1}{1-z}\sum_{a=0}^{49}\,\sum_{b=0}^{49-a}z^{4a+3b}\,\sum_{c=0}^{49-a-b}z^{2c}\\ &\qquad-[z^{46}]\frac{1}{1-z}\sum_{a=0}^{49}\,\sum_{b=0}^{49-a}z^{3a+2b}\,\sum_{c=0}^{49-a-b}z^{c}\tag{5}\\ &=[z^{96}]\frac{1}{1-z}\sum_{a=0}^{49}\,\sum_{b=0}^{49-a}z^{4a+3b}\,\frac{1-z^{100-2a-2b}}{1-z^2}\\ &\qquad-[z^{46}]\frac{1}{1-z}\sum_{a=0}^{49}\,\sum_{b=0}^{49-a}z^{3a+2b}\,\frac{1-z^{50-a-b}}{1-z}\tag{6}\\ &=[z^{96}]\frac{1}{(1-z)(1-z^2)}\sum_{a=0}^{49}z^{4a}\,\sum_{b=0}^{49-a}z^{3b}\\ &\qquad-[z^{46}]\frac{1}{(1-z)^2}\sum_{a=0}^{49}z^{3a}\,\sum_{b=0}^{49-a}z^{2b}\tag{7}\\ &=[z^{96}]\frac{1}{(1-z)(1-z^2)}\sum_{a=0}^{49}z^{4a}\,\frac{1-z^{150-3a}}{1-z^3}\\ &\qquad-[z^{46}]\frac{1}{(1-z)^2}\sum_{a=0}^{49}z^{3a}\,\frac{1-z^{100-2a}}{1-z^2}\tag{8}\\ &=[z^{96}]\frac{1}{(1-z)(1-z^2)(1-z^3)}\,\frac{1-z^{200}}{1-z^4}\\ &\qquad-[z^{46}]\frac{1}{(1-z)^2(1-z^2)}\,\frac{1-z^{150}}{1-z^3}\tag{9}\\ &\,\,\color{blue}{=[z^{96}]\frac{1}{(1-z)(1-z^2)(1-z^3)(1-z^4)}}\\ &\qquad\color{blue}{-[z^{46}]\frac{1}{(1-z)^2(1-z^2)(1-z^3)}}\tag{10}\\ \end{align*} \begin{align*} &=[z^{96}]\left(\frac{1-z^2}{9(1-z^3)}+\frac{1}{8(1+z^2)}+\frac{4z+5}{32(1+z)^2}\right.\\ &\qquad\qquad\qquad\left.-\frac{68z^3-263z^2+358z-175}{288(1-z)^4}\right)\\ &\qquad-[z^{46}]\left(\frac{1-z^2}{9(1-z^3)}+\frac{1}{16(1+z)}\right.\\ &\qquad\qquad\left.-\frac{25z^3-109z^2+179z-119}{144(1-z)^4}\right)\tag{11}\\ &=\frac{1}{9}[z^{96}](1-z^2)\sum_{j=0}^{\infty}z^{3j}+\frac{1}{8}[z^{96}]\sum_{j=0}^{\infty} (-1)^jz^{2j}\\ &\qquad+\frac{1}{32}[z^{96}](4z+5)\sum_{j=0}^{\infty} (j+1)(-1)^jz^j\\ &\qquad-\frac{1}{288}[z^{96}]\left(68z^3-263z^2+358z-175\right)\sum_{j=0}^{\infty}\binom{j+3}{3}z^j\\ &\qquad+\frac{1}{9}[z^{46}](1-z^2)\sum_{j=0}^{\infty}z^{3j}-\frac{1}{16}[z^{46}]\sum_{j=0}^{\infty}(-1)^jz^j\\ &\qquad+\frac{1}{144}[z^{46}]\left(25z^3-109z^2+179z-119\right)\sum_{j=0}^{\infty}\binom{j+3}{3}z^j\tag{12}\\ &=\frac{1}{9}+\frac{1}{8}+\frac{1}{32}\left(-4\cdot 96+5\cdot 97\right)\\ &\qquad-\frac{1}{288}\left(68\binom{96}{3}-263\binom{97}{3}+358\binom{98}{3}-175\binom{99}{3}\right)\\ &\qquad+0-\frac{1}{16}\\ &\qquad\qquad+\frac{1}{144}\left(25\binom{47}{4}-109\binom{48}{4} +179\binom{49}{4}-119\binom{50}{4}\right)\tag{13}\\ &=\left(\frac{1}{9}+\frac{1}{8}+\frac{101}{32}+\frac{2\,059\,087}{288}\right)-\left(\frac{1}{16}+\frac{484\,407}{144}\right)\\ &=7\,153-3\,364\\ &\,\,\color{blue}{=3\,789} \end{align*}

in accordance with the result stated by @antkam.

Comment:

  • In (2) we write the sums more conveniently as preparation for the following transformations.

  • In (3) we transform the indices so that they start from $0$. This is done by \begin{align*} a\to a+1,\quad b\to b-a-1,\quad c\to c-b-a-1,\quad d\to d-c-b-a-1 \end{align*}

  • In (4) we factor out $z^4$, apply the rule $[z^p]z^qA(z)=[z^{p-q}]A(z)$ and use the finite geometric summation formula for the inner most sum.

  • In (5) we split the sums and do some rearrangements as preparation for the next appliction of the finite geometric summation formula.

  • In (6) we apply the geometric summation formula as we did in (4).

  • In (7) we skip the terms containing the factor $z^{100}$ and $z^{50}$ as they do not contribute to the wanted coefficients.

  • In (8) to (10) we work similarly as we did before.

  • In (11) we do a partial fraction expansion (admittedly with some help of Wolfram Alpha) which helps to extract the coefficients easily.

  • In (12) we do geometric and binomial series expansions.

  • In (13) we select the coefficients accordingly.


As far as I can tell, there are several theoretical ways to solve this, but all of them involve some sort of enumerating / recurrence / looping, and there is no closed form solution. Since your problem is so small ($4$ numbers, max size $50$, total $100$), a simple quadruply-nested loop might take the least amount of total coding + running time. In fact I just did it: it took $< 1$ minute to code and $< 1$ second to run, and the answer is $3789$, as @Semiclassical already pointed out using Mathematica.

Anyway, the exact form of your problem is a number partition with both restricted part size (max part size $=50$) and restricted number of parts (exactly $4$ parts). This is described in this section of wikipedia. The solution is given in terms of a recurrence with $3$ parameters - the total, the max part size, and the number of parts - so if you want to use that solution you'd still have to write the equivalent of a triple-loop. Since you have only $4$ parts (variables), a brute-force quad-loop is easier.

Note that the wikipedia section quoted above answers the question for "at most $M$ parts" whereas you have "exactly $M$ parts". However, you can transform between them by the change of variables $a' = a - 1, b' = b-1$ etc and allowing the $a', b', c', d'$ to be zero (hence at most $4$ parts, since zeros don't count as parts) and changing the sum to $96$ and the max part size to $49$.