# Number of ways to place n balls into m boxes

1. Sep 11, 2010

### KFC

Let's consider a simple case with 2 balls and 3 boxes. Assuming all balls are the same and empty box is allowed. In addition, each box can take any number of ball. How many ways are there to place the balls into the boxes?

Here is my way to solve the problem. For the first ball, there are 3 ways to do so. For the second ball, still 3 ways. So total 9 ways to place 2 balls into 3 boxes. For the general way, my conclusion is $$m^n$$

2 0 0
0 2 0
0 0 2
1 0 1
0 1 1
1 1 0

There are only six ways. So what's wrong with my analysis? And what's the correct expression for this case?

2. Sep 11, 2010

### JSuarez

You are overcounting. When you say:

You are distinguishing the balls. The correct way of counting this type of problems, with repetition but without order is like this (the two 0's separate the three boxes):

1100, 0110, 0011, 1010, 1001, 0101

In the general case, this is counting the number of lenght n binary sequences with exactly k 0's and there is a well-known expression for this.

Last edited: Sep 11, 2010
3. Sep 14, 2010

### JeSuisConf

Last edited by a moderator: Apr 25, 2017
4. Sep 14, 2010

### Little ant

we can colocated the first ball at box 1, box 2 or box 3. Then you can put the second ball at box 1 box 2 or box 3, so, for one ball, you have 3 options, and are 2 ball. to generalize, if you have n balls, and m positions for each ball, the posibles combinations are equal to product m.n and you can verify than 2.3=6

5. Sep 16, 2010

### KFC

Thanks for your reply. But base on your reasoning, if I have 3 boxes and 4 balls, there are 3*4 = 12 ways to place the balls? But the answer if 15

6. Sep 16, 2010

### Little ant

n¡*(m-1)¡

7. Sep 16, 2010

### Little ant

. n¡*(m-1)¡

8. Sep 16, 2010