Problems related to balls and boxes can be classified mainly into 4 categories.
This case is one of the most interesting case. This can be solved in many ways.
We first divide 5 balls into 3 different groups and then we allocate these groups into 3 boxes.
But when any of m,n, or p are same we have to divide by that similar numbers. Here in 2, 2, 1 two 2's are same. So final answer should be divided by 2!.
Suppose your dad has given you 100 rupees to buy ice-creasms. Let us say an ice cream costs you Rs.25. In an ice cream shop there are 5 varieties of ice cream available. Chololate, Vanilla, strawberry, Butter scotch, Pista.You can buy any varieties but you can buy maximum 4 ice creams as an ice cream costs you Rs.25 each.
This is a problem of finding intezer solutions to the above equation where sum of all the numbers in the places of 5 different ice creams is equal to 4.
We can apply the same logic to the balls and boxes where balls are similar (as ice creams of same variety are similar) but the sum of the balls in all the boxes together must equal to 4.
Now A + B + C + D = 4 where any of these numbers can be Zero.
In this case we should take only natural numbers as 0 is not allowed.
This is one of the typical probelm where we attempt to solve it by using a special recurrence table called Stirling numbers of second kind.
Here column N represents number of balls and K represents number of boxes.
Now 4 ball and 4 boxes can be arranged in 1 + 7 + 6 + 1 = 15 ways.