# Is there a better way to find the number of integer solutions

## Homework Statement

# of integer solutions of x1+x2+x3+x4 = 32

where x1,x2,x3>0 and 0<x4≤25

## The Attempt at a Solution

So in the case where x4 = 25 we have

x1+x2+x3= 4

in the case where x4 = 24 we have

x1+x2+x3 = 5

.....

in the case where x4 = 1 we have

x1+x2+x3 = 28

so we can do x1+x2+x3+x4 = 28

which will give us f = 31!/3!28!

now we subtract f - g where g =

x1+x2+x3 < 4

(31!/(3!28!)) - (6!/(3!3!))

= 4475

The answer is correct but I don't know if my method is a good one. Can anyone let me know?

mfb
Mentor
That should be by far the easiest approach.
which will give us f = 31!/3!28!
To motivate this a bit (not for you, but for other readers): Imagine 28 written as 28 "1"s with three separators to form four groups: 111|11||11111111111111111111111. Now let x1 be the size of the first group plus one, x2 be the size of the second group plus one and so on. My example corresponds to 32 = 4+3+1+24. There is a one to one relation between the sums and the 1/separator strings. There are (31 choose 3) options for the places of the separators. This is the total number of ways to write 32 as sum of four positive integers. Afterwards the ways with x4>25 are subtracted.

verty
Homework Helper
OP, your post doesn't make sense. First it is 32, then it is 28. Which is it? Also I get a different answer: 4460 (no, it is 4475, I thought x4 < 25). You'll need to be much more clear before I give any further information about my method.

Homework Helper
Gold Member
2020 Award
The OP apparently is doing the case of 28, but I think he is also doing ## x_4<25 ##. If it is ## x_4 \leq 25 ##, the second term should be ## \frac{5!}{2! \, 3!} ## because the term that would be subtracted is the number of ways that ## x_1+x_2+x_3 ## can be 2 or less.

mfb
Mentor
Let's check the excluded cases individually:
x4=26 gives x1+x2+x3=6 which has just the options 1+1+4, 1+2+3, 2+2+2 and permutations of it (total: 3+6+1=10).
x4=27 gives x1+x2+x3=5 which has just the options 1+1+3, 1+2+2 and permutations of it (total: 3+3=6).
x4=28 gives x1+x2+x3=4 which has just the option 1+1+2 and permutations of it (total: 3).
x4=29 gives x1+x2+x3=3 which has just the option 1+1+1 (total: 1).

-> we have to subtract 20. Or (6 choose 3) as can be derived in the same way as the (31 choose 3). This time we are interested in the number of ways x1+x2+x3 ≤ 6, or x1+x2+x3+y ≤ 7 with a positive y to get the same situation as before. The answer in post 1 is correct.