Answer the question
The answer is n!S(m,n) , where S the Stirling number of the second kind .
For example, for m=4, n=3 , n!=6 , S(4,3)=6 , so n!S(m,n)=36 , which is the expected answer.
Why is this formula?
Stirling numbers of the second kind S(m,n) count the number of ways to split the set of elements m into n nonempty subsets. So, for this question S(m,n) count the number of ways to split m into groups n , each of which corresponds to a digit. After the section, we must assign one digit to each group, and there is n! ways to do it. Therefore, the answer is n!S(m,n) .
source share