Kloster's Pen Problem

in #mathematics7 years ago

My roommate posed this problem to me about a week ago.

I posted it on math.stackexchange.com and got a response which led me to look up some numbers on the Online Encyclopedia for Integer Sequences (OEIS).

I just figured I'd pose the question here along with the answer now.

If you have M pens, each of a different color, and each of which have N parts, then how many ways can you put them back together so that at least one pen is a solid color?


The answer is the following for m pens and n pieces per pen:


Bonus points to anyone who can explain it!