How many ways are there to partition an $n$-element set where $n \geq k$ into $k$ nonempty subsets?
According to the formula provided here, the answer is $\dfrac{1}{k!}\displaystyle\sum_{i=0}^k (-1)^i{k\choose i} (k-i)^n.$ However I don't understand how this formula was derived. I have a rough idea of why combinatorics are involved here as we have to choose elements from a set. Also, there are $k!$ repetitions, so we have to divide by $k!$. However, why is the sum alternating (does this have to do w/ the use of complements?) and what is the significance of the term $(k-i)^n$?