Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the total number of solutions of an equation of the form $x_1 + x_2 + \cdots + x_r = m$ such that $1 \le x_1 < x_2 < \cdots < x_r < N$ where $N$ is some natural number and $x_1, x_2, \cdots, x_r, m$ are integers?

Also, what would be the solution in the relaxed case where $x_1, x_2, x_3, \dots, x_r$ could be equal?

share|cite|improve this question
Looks like a restricted partition function, and will not have an easy formula. – anon May 1 '12 at 22:43
Is $r{}$ fixed? – Gerry Myerson May 1 '12 at 23:21
yes, r is fixed. – Randomks May 2 '12 at 5:40

Presumably $m \ge 0$. Here are two ways of getting your answer.

1) If $F(N,m)$ is the number of such solutions, then by conditioning on the value of $x_r$ we have

$$F(N,m) = \sum_{x=1}^{\min(m,N-1)} F(x,m-x)\ \text{for}\ m \ge 1$$

with $F(N,0) = 1$, $F(1,m) = 0$ for $m \ge 1$.

2) $F(N,m)$ is the coefficient of $x^m$ in $\prod_{j=1}^{N-1} (1+x^j)$.

See also

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.