0

Suppose I have following equation:

$$ a_1 + a_2+\cdots+a_k=n$$ $$a_1,a_2,\cdots,a_k\in\{m,m+1,m+2,\cdots,m+l \}$$ and $$m*k<n$$

I am asked to calculate how many different solution that equation has. What I came up with is changing variables: $a_i=a_i'+m$ and then my equation looks like this: $$ a_1' + a_2'+\cdots+a_k'=n-k*m$$ $$a_1',a_2',\cdots,a_k'\in\{0,1,2,\cdots,l \}$$ It may seem a little nicer to solve but still there's that $l$ limitation which I am not so sure know what to do with. Is there any "general" method to do this type of task? I already tried substituting one of variables like that: $a_i'=a_i''+l+1$ and then solving "smaller" equation but it just doesn't feel like the right way to do this.

My original equation is: $$a+b+c+d=45$$ $$a,b,c,d\in\{5,6,\cdots,15\}$$

I'll be thankful for any help or tips.

Igor
  • 457
  • So are you looking for a solution to the first equation set or the second? The second is the kind of thing I'd solve with generating functions, but the first seems just a tad messier with the $km<n$ restriction. – PrincessEev Apr 14 '19 at 20:20
  • @EeveeTrainer I just wanted to make sure that my first change of variables will be okay this is why this restriction is there – Igor Apr 14 '19 at 20:24

1 Answers1

0

The first step is correct. You have reduced the problem to finding the number of compositions of a number $n$ into $k $ parts with the largest possible value of a part being equal to $l $.

The answer to the problem is well-known and reads: $$\sum_{i=0}^{\left\lfloor\frac n{l+1}\right \rfloor}(-1)^i\binom{k}i\binom{n-i(l+1)+k-1}{k-1}.\tag1$$

A proof can be found here.

PS. Do not forget that in your case $n $ in $(1) $ should be replaced with $n-km$.

user
  • 26,272