I have four positive numbers $a_1,\dots,a_4$, each less than $45$. How many different ways are there for $a_1+a_2+a_3+a_4<90$? I require different permutations i.e $a_1a_2a_3a_4$ is different from $a_2a_1a_4a_3$
3 Answers
Here is one solution by generating functions: Let $F(x)=(x+x^2+\cdots+x^{44})^4(x+x^2+\cdots)$. I claim that we seek the coefficient of $x^{90}$. Indeed, the statement is equivalent to $a_1+a_2+a_3+a_4+c=90$, for some positive $a_1,\cdots a_4,c$ with $a_1,\cdots a_4<45$. The coefficients of $(x+x^2+\cdots+x^{44})^4$ represent the number of ways to choose $1\le a_1,\cdots a_4\le 44$ such that they add to a certain exponent. The $(x+x^2+\cdots)$ term does the same thing, but there is no upper bound.
Now, we rearrange and obtain $$ F(x)=\frac{x^5(1-x^{44})^4}{(1-x)^5}=\frac{x^{181}-4 x^{136}+6 x^{93}-4 x^{49}+x^5}{(1-x)^5} $$ It is well known that the coefficient of $x^k$ in $\frac{1}{(1-x)^m}$ is $\binom{m+k-1}{k}$ (this can be easily proven by induction by using $\frac{1}{(1-x)}=1+x+x^2+\cdots$). Then the number that we seek is $$ -4\binom{45}{41}+\binom{89}{85}=1845646 $$ Which was confirmed with Java.

- 1,521
- 7
- 7
If you consider $(a_1,a_2,a_3,a_4)$ the same as $(a_1,a_2,a_4,a_3) \ \ldots$ then according to python the answer is $90316$. If $(a_1,a_2,a_3,a_4)$ and $(a_1,a_2,a_4,a_3)$ are considered different $\ldots$ then the answer is $1898622$.

- 14,929
-
I do not require direct answer. I want to solve it by permuatation and combinations – Prannoy Mittal Nov 09 '12 at 08:32
OP wanted a permutation and combination solution, and the two posted solutions don't tally, so here is a Stars and Bars Th.1 approach.
Here we necessarily need a positive slack variable s to convert this inequality, which is of the $<$ type, into an equality, and so we need to solve $a_1+a_2+a_3+a_4+s = 90$ over the positive integers, and by Th. $1$ of stars and bars, along with inclusion-exclusion (actually, just exclusion, as luckily only one variable can violate the upper bound), we get $$Answer\; = \binom{89}{4} - 4\binom{45}{4}= 1845646$$

- 41,295
-
For $a_i<45$ the value $1845646$ is correct. The value $1898622$ is obtained for $a_i\le45$. – Daniel Mathias Oct 06 '23 at 03:13
-
-
But it is taking c (the slack variable) to be necessarily $\ge1$ – true blue anil Oct 06 '23 at 15:39
-
-
permutations
tag. Is this correct? – Cameron Buie Nov 09 '12 at 06:25