Combinatorics – Integer Partition of n into k Parts Recurrence

combinatoricsinteger-partitionsrecurrence-relations

I was learning integer partition of a number n into k parts(with minimum 1 in each part) and came across this recurrence :

part(n,k) = part(n-1,k-1) + part(n-k,k)

But, I cannot understand the logic behind this recurrence. Can someone please help me visualize this recurrence?

Best Answer

$p(n,k)$ is the number of ways to partition $n$ into $k$ parts. It is the same as the number of different ways of placing $n$ objects into $k$ pots. Firstly put $1$ object in each pot. Total $k$ objects have been put and now we have to put remaining $n-k$ objects into $k$ pots. Hence, $$ p(n,k)=p(n-k,1)+p(n-k,2)+\cdots+p(n-k,k-1)+p(n-k,k)$$ Also observe that, $$ p(n-1,k-1)=p(n-k,1)+p(n-k,2)+\cdots+p(n-k,k-1)$$ From the above two equations, we conclude: $$p(n,k)=p(n-1,k-1)+p(n-k,k)$$