I randomly encountered this post here, asking why this is true:
def subset(n, k):
if k == 0:
return 1
if n == k:
return 1
else:
return subset(n-1, k-1) + subset(n-1, k)
Without reading the answer, I tried to understand the concept and it turned out not that complicated.
I wrote it as a math formula:
$${n \choose k} = {n-1 \choose k-1}+{n-1 \choose k}$$
This makes great sense when written down graphically on a piece of paper, but now I would like to know how to prove it mathematically.
Whould an induction proof be the correct one? As I only had 1 variable in my induction proofs before, this seems to be more complex.
My hypothesis:
- Prove the above for ${0 \choose 0}$
- Prove the above for ${n+1 \choose k}$
- Prove the above for ${n \choose k+1}$
- Prove the above for ${n+1 \choose k+1}$
Then, every possibility starting from ${0 \choose 0}$ would be covered. But imagine a formula having 5 variables, then this would imply at least $5^5$ proofs.
So is my approach correct? Is there a more elegant way of doing it?
Thank you!