# Diophantine equation with 1 and 3

In a certain exercise I am asked to say how many possible solutions are there for the diophantine equation $$x_1 + x_2 + \cdots + x_{20} = 50$$, with the condition that $$x_i$$ can only be or 1 or 3. Here is my attempt:
To begin with, one has to choose how many 3 can be. Taking into account that there are at most 20 $$x_i$$ that can add up to the number on the right side and that those $$x_i$$ can only be 1, I ended up with the fact that the only possible solution would be having 15 threes and therefore the sum of the remaining 5 members would be 5, so the remaining members would all be 1. The only thing missing is ordering those threes: the answer is therefore $$20 \choose 15$$. Is this correct, or am I missing something?

Yes, it's correct. You can do this faster by subtracting $$20$$ and dividing by $$2$$ on both sides, then letting $$y_i=(x_i-1)/2\in\{0,1\}$$ to give $$\sum_{i=1}^{20}y_i=15$$ which is now obvious.
Assuming that order of $$\{x_i\}$$ matters, your answer is correct. However, if order of $$\{x_i\}$$ does not matter than the answer is $$1$$.
• Yes, the order of $x_i$ matters since these are different variables Oct 3 at 11:27