Problem Description
Implement the Combinations by the formula using recursive function calls
nCk = (n−1)C(k−1) + (n−1)Ck
where
nC0=nCn=1
Read two user input n and k and report all combinations calculated in the process.
For example, if user input n = 3 and k = 1
3C1 = 2C0 + 2C1
2C0 = 1
2C1 = 1C0 + 1C1
1C0 = 1
1C1 = 1
2C1 = 2
3C1 = 3
If user input n = 4 and k = 2
4C2 = 3C1 + 3C2
3C1 = 2C0 + 2C1
2C0 = 1
2C1 = 1C0 + 1C1
1C0 = 1
1C1 = 1
2C1 = 2
3C1 = 3
3C2 = 2C1 + 2C2
2C1 = 1C0 + 1C1
1C0 = 1
1C1 = 1
2C1 = 2
2C2 = 1
3C2 = 3
4C2 = 6
If user input n = 5 and k = 5
5C5 = 1
Implement the Combinations by the formula using recursive function calls
nCk = (n−1)C(k−1) + (n−1)Ck
where
nC0=nCn=1
Read two user input n and k and report all combinations calculated in the process.
For example, if user input n = 3 and k = 1
3C1 = 2C0 + 2C1
2C0 = 1
2C1 = 1C0 + 1C1
1C0 = 1
1C1 = 1
2C1 = 2
3C1 = 3
If user input n = 4 and k = 2
4C2 = 3C1 + 3C2
3C1 = 2C0 + 2C1
2C0 = 1
2C1 = 1C0 + 1C1
1C0 = 1
1C1 = 1
2C1 = 2
3C1 = 3
3C2 = 2C1 + 2C2
2C1 = 1C0 + 1C1
1C0 = 1
1C1 = 1
2C1 = 2
2C2 = 1
3C2 = 3
4C2 = 6
If user input n = 5 and k = 5
5C5 = 1