Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to prove $$n^n=\sum\limits_{\substack{k,i_1,\ldots, i_k\ge1,\\ i_1+\cdots+i_k=n}}\frac{n!}{i_1!\cdots i_k!}i_1^{i_1-1}\cdots i_k^{i_k-1}=\sum\limits_{k=0}^n {n\choose k}(k+1)^{k-1}(n-k-1)^{n-k}\qquad?$$ Thanks.

(Note: The OP sent me additional information on the question via email. If I understand it correctly, it amounts to the following hints. -- Mike Spivey.)

Let $X = \{1,2,\ldots,n\}$.

Hint on first equality: Show that every function $\alpha:X \to X$ can be represented uniquely as a permutation of the trees in a rooted forest on $n$ labeled nodes.

Hint on second equality: Show that every function $\alpha:X \to X$ can be represented uniquely as an ordered pair, the first element of which is a rooted tree in which the all nodes except the root are labeled, and the second of which is a function $\alpha': S \to S$ in which $\alpha'(i) \neq i$ (i.e., $\alpha'$ has no fixed points) and $S \subset X$.

share|cite|improve this question
Wow, that index set is quite ugly! – Jonas Teuwen Oct 26 '11 at 21:06
What are your thoughts so far? – Mike Spivey Oct 26 '11 at 21:13
Ugly is in the eye of the beholder. It's just a sum over all sets of positive integers adding up to $n$. Quite common in combinatorics. – Gerry Myerson Oct 26 '11 at 21:38
up vote 6 down vote accepted

(For my original answer, see the end of the post.)

This answer gives a combinatorial argument for both identities, using the hints above. It leans heavily on ideas from Section 12 in these notes.

First, if $X = \{1, 2, \ldots, n\}$, we know that there are $n^n$ functions $\alpha:X \to X$.

First identity: Any function $\alpha: X \to X$ can be represented as a labeled, directed graph $G_\alpha$ with vertex set $X$, where $(i,j)$ is an edge in the graph if $\alpha(i) = j$. Suppose we start at some vertex $i \in G_\alpha$. Since $X$ is finite, and any vertex with $\alpha(j) = j$ has a self-loop, if we continue following directed edges in the graph -- from $i$ to $\alpha(i)$ to $\alpha(\alpha(i))$ and so forth -- we must eventually reach a vertex already visited. In other words, every sufficiently long directed path in $G_\alpha$ ends in a cycle. This means that each connected component of $G_\alpha$ consists of a set of trees attached to a cycle. (A tree may also consist of a single node.) Moreover, we can think of each tree as rooted by the vertex that is common to the tree and the cycle that it ends in. (See, for example, the picture at the bottom of page 4 here.) Since a set of disjoint cycles is just a permutation, the roots of the trees together with the edge set $(i,j)$ for each root $i$ form a permutation of the labels of the roots. Therefore, any function $\alpha: X \to X$ can be thought of as a permutation of the trees (via their roots) in a forest on the vertex set $\{1, 2, \ldots, n\}$.

All of this means that we can uniquely specify a function $\alpha: X \to X$ by

  1. Choosing a number of rooted trees and a multiset of sizes of those trees,
  2. Choosing a permutation of the multiset of tree sizes,
  3. Distributing the labels $1, 2, \ldots, n$ among the trees, and
  4. Choosing a labeled, rooted tree structure for each element in the multiset of tree sizes.

Steps 1 and 2 correspond to choosing a $k$ and $i_1, i_2, \ldots, i_k$ such that $i_1 + i_2 + \cdots + i_k = n$. For Step 3, we are distributing $n$ labels among sets of size $i_1, i_2, \ldots, i_k$, and thus Step 3 can be done in $\binom{n}{i_1, i_2, \ldots, i_k} = \frac{n}{i_1! i_2! \cdots i_k!}$ ways. For Step 4, Cayley's formula tells us that there are $n^{n-2}$ labeled trees with $n$ vertices. Since there are $n$ ways of selecting a root, there are $n^{n-1}$ rooted, labeled trees with $n$ vertices. Thus there are $i_1^{i_1-1} i_2^{i_2-1} \cdots i_k^{i_k-1}$ ways to perform Step 4. Putting all of this together yields $$n^n=\sum\limits_{\substack{k,i_1,\ldots, i_k\ge1,\\ i_1+\cdots+i_k=n}}\frac{n!}{i_1!\cdots i_k!}i_1^{i_1-1}\cdots i_k^{i_k-1}.$$

Second identity: Break the connected components of $G_\alpha$ into two groups: 1) those that end in a cycle consisting of a single vertex, and 2) those that end in a cycle consisting of more than one vertex. For the first group, create a new, unlabeled vertex. Attach the root of each tree in the first group to the new, unlabeled vertex to create a single rooted tree in which all vertices except the root are labeled. Since the second group has no vertices for which $\alpha(i) = i$, it can be thought of as a function $\alpha':S \to S$, for $S \subset X$, such that $\alpha'(i) \neq i$ for any $i$. Thus we can uniquely specify a function $\alpha: X \to X$ by

  1. Choosing a subset $X-S$ of $X$ to comprise the elements in the first group,
  2. Choosing a rooted tree structure on $X-S$ in which all vertices except the root are labeled, and
  3. Choosing a function $\alpha':S \to S$ with no fixed points.

For a fixed size $k$ of $X - S$, there are $\binom{n}{k}$ ways to perform Step 1. A rooted tree with labels on all vertices except the root is equivalent to a completely labeled tree with no root, so there are, by Cayley's formula, $(k+1)^{k-1}$ ways to perform Step 2. Finally, there are $(n-k-1)^{n-k}$ functions from a set of size $n-k$ to itself that contain no fixed points. Putting all of this together yields $$n^n =\sum\limits_{k=0}^n {n\choose k}(k+1)^{k-1}(n-k-1)^{n-k}.$$

Original answer:

The second equality follows from Abel's variation on the binomial theorem: $$\sum_{k=0}^m \binom{m}{k} (w+m-k)^{m-k-1}(z+k)^k=w^{-1}(z+w+m)^m.$$

Let $m = n, w = 1, z = -1$ to get $$\sum_{k=0}^n \binom{n}{k} (n-k+1)^{n-k-1}(k-1)^k=n^n.$$ Then, reindexing the sum via $k \to n-k$ yields the second identity $$\sum_{k=0}^n \binom{n}{k} (k+1)^{k-1}(n-k-1)^{n-k}=n^n.$$

For a short proof of Abel's binomial theorem, see this recent paper by Chu. A generalization of it also appears as Equation 5.64 in Concrete Mathematics (2nd ed., p. 202).

share|cite|improve this answer
Thanks a lot, Mike. – Sunni Oct 27 '11 at 20:38
@Sunni: This seems like a very hard homework problem to me. What are you allowed to assume? Would you be allowed to use Abel's identity? Or would you be expected to prove it from scratch or give a combinatorial argument in favor of it? – Mike Spivey Oct 27 '11 at 20:43
Indeed this is a hard homework problem,I haven't heard of abel's variation before,I was wondering any interesting application of te same? – Quixotic Oct 27 '11 at 23:16
@ Mike: Thanks very much for your detailed answer. I understand it now. – Sunni Oct 30 '11 at 4:25
@Sunni: You're welcome. I enjoyed thinking about it; before your question I hadn't known that endofunctions could be represented in these two ways. – Mike Spivey Oct 30 '11 at 4:33

HINT: What is the sum of all coefficients of the expansion $ (x_1 + x_2 + \cdots + x_n)^n $?

You may read more here.

share|cite|improve this answer
The multinomial theorem doesn't work here because (1) the $x_i$ cannot cannot change from term to term in the sum (so they can't be index variables), and (2) the exponents in the OP's identity aren't quite of the right form. – Mike Spivey Oct 27 '11 at 2:44
What is the explanation of the second equality? – Sunni Oct 27 '11 at 13:26
@Sunni:I am sure we could use mathematical induction to prove the second one. – Quixotic Oct 27 '11 at 13:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.