Number of ways to choose N integers that sum up to X

In summary, the problem is to find the number of ways to choose N positive integers that sum to a fixed positive integer X. For N=1, there is only 1 choice. For N=2, there are X-1 ways. For N=3, there are (X-1)(X-2)/2 ways. For N>3, generating functions can be used to find the number of combinations, and the formula for the number of permutations is {X-1 \choose N-1}. This problem is related to the number of ways to place r indistinguishable balls into n distinguishable boxes, which is given by {r-1 \choose n-1}.
  • #1
mnb96
715
5
Hello,
is there a straightforward way, or some well-known expression to count how many ways there are of choosing N positive integers [itex]a_1,\ldots,a_N[/itex] such that [itex]a_1+\ldots+a_N = X[/itex] (where X is some fixed positive integer).

Note that if N=2, and X=10 (for example), I consider the pairs 1+9 and 9+1 (for instance), as being two different ways of obtaining X=10, as well as 2+8 and 8+2, or 3+7 and 7+3, and so on...

For N=1 there is obviously only 1 choice.
For N=2 the result should be: X-1 ways.
For N=3 it is (X-1)(X-2)/2

...For N>3 things get more complicated...
 
Physics news on Phys.org
  • #2
You could use a "generating functions" to find the number of combinations of integers that sum to a given number. Then you might be able to infer the number of permutations from that answer. A search for "generating functions ways of making change" turns up many expositions, for example this PDF explains it: http://ocw.mit.edu/courses/mathematics/18-310c-principles-of-applied-mathematics-fall-2007/lecture-notes/22_2_ln.pdf

If anyone knows a way to use generating functions to get the answer for the number of permutations directly, I'd like to hear about it.
 
Last edited by a moderator:
  • #3
The answer is: [tex]{X-1 \choose N-1}[/tex]

This problem is related to the following:
The number of ways to place r indistinguishable balls into n distinguishable boxes such that no box is empty is given by

[tex]{r-1 \choose n-1}[/tex]

See:
http://msor.victoria.ac.nz/twiki/pub/Courses/MATH261_2011T1/WebHome/notes_2.pdf"

To understand the formula we consider 10 balls:
o o o o o o o o o o

Suppose we are interested in how many ways we can represent 10 as a sum of 3 variables:
a1 + a2 + a3 = 10

We can model this by dividing the 10 balls into 3 blocks, for example:
o o o | o o | o o o o o

Obviously, we need 2 dividers to form 3 blocks. All we need to do is count the number of ways we can place
the dividers between the balls. For 10 balls there are 9 spaces between the balls. Thus, there are 9 positions for the 2 dividers yielding

[tex]{9 \choose 2}[/tex] possibilities.


Summary:
r=10 balls, n=3 blocks
=> r-1 positions for n-1 dividers

possibilities: [tex]{r-1 \choose n-1} = {9 \choose 2}[/tex]
 
Last edited by a moderator:

1. How do you calculate the number of ways to choose N integers that sum up to X?

The number of ways to choose N integers that sum up to X can be calculated using the stars and bars method. This method involves dividing the X into N groups and placing N-1 bars between them. The number of ways to arrange these stars and bars is equal to the number of ways to choose N integers that sum up to X.

2. What is the formula for calculating the number of ways to choose N integers that sum up to X?

The formula for calculating the number of ways to choose N integers that sum up to X is (X+N-1) choose (N-1). This can also be written as (X+N-1)! / (N-1)! X!.

3. Can the number of ways to choose N integers that sum up to X be negative?

No, the number of ways to choose N integers that sum up to X cannot be negative. It is always a positive integer as it represents the number of possible combinations to reach the desired sum.

4. How does the value of N affect the number of ways to choose N integers that sum up to X?

The value of N directly affects the number of ways to choose N integers that sum up to X. As N increases, the number of ways increases exponentially. For example, if X is a large number and N is relatively small, there will be significantly fewer ways to choose N integers that sum up to X compared to if N was a larger number.

5. Can the number of ways to choose N integers that sum up to X be greater than X?

No, the number of ways to choose N integers that sum up to X cannot be greater than X. This is because the maximum possible sum of N integers is N times the largest integer, which is still less than X. Therefore, the number of ways to choose N integers that sum up to X is always less than or equal to X.

Similar threads

  • Linear and Abstract Algebra
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
33
Views
3K
  • Linear and Abstract Algebra
Replies
8
Views
2K
  • Linear and Abstract Algebra
Replies
15
Views
4K
  • Calculus and Beyond Homework Help
Replies
1
Views
255
  • Calculus and Beyond Homework Help
Replies
7
Views
2K
  • Precalculus Mathematics Homework Help
Replies
3
Views
1K
Replies
1
Views
673
  • Set Theory, Logic, Probability, Statistics
Replies
12
Views
966
  • Differential Equations
Replies
7
Views
390
Back
Top