# Find the number of ways to put the 7 balls (Distinct) into the 3 boxes (Distinct) without any restrictions?

Find the number of ways to put the 7 balls (Distinct) into the 3 boxes (Distinct) without any restrictions ?

I know that answer will be $3^7$ as I can write this as

$F : { 1,2,3,4,5,6,7 } -> { a,b,c }$

But, I want to know how Stirling formula of second kind solves this :-->

=> Number of ways to put all balls in 1 box + Number of ways to put all balls in 2 boxes + Number of ways to put all balls in 3 boxes

=> $1!.S(7,1) + 2!.S(7,2) + 3!.S(7,3)$

=> This gives 1933 but it should be $3^7$ = 2187

Where am I going wrong ?

The number of ways of getting exactly k different values when you throw n fair r-sided dice is

$\binom{r}{k}\cdot S_2(n,k)\cdot k!$

Thus for your problem, $\binom31\cdot 1 \cdot1! + \binom32 \cdot 63 \cdot 2! + \binom33\cdot 301\cdot3! = 2187$

Every ball can be put into one of the three boxes. Since balls and boxes are distinct, these choices are entirely independent.

Then you must clearly have $3^7=2187$ possible different arrangements.

• I want to solve this using Stirling formula. I know by this method. – Jon Garrick Nov 10 '16 at 10:15

Consider each ball, one-by-one. For the first ball, we have 3 choices (1 for each box). For the second ball, we have again three choices, making $9=3^2$ possibilities so far. Continuining in this way, we have $3\times 3\times 3\times 3\times 3\times 3\times 3 = 3^7$ possibilities.

• I want to solve this using Stirling formula. I know by this method. – Jon Garrick Nov 10 '16 at 10:15