Question: #my code def mCn(m, n): if n ==0 or m == n: print(str(m) + C + str(n) + = 1) return True else: print(str(m)

#my code

def mCn(m, n):

if n ==0 or m == n:

print(str(m) + "C" + str(n) + " = 1")

return True

else:

print(str(m) + "C" + str(n) + " = " + str(m-1) + "C" + str(n-1) + " + " + str(m-1) + "C" + str(n))

print(str(m) + "C" + str(n) + " = " + str(mCn(m-1, n-1) + mCn(m-1, n)))

return True

m = int(input())

n = int(input())

mCn(m, n)

However, following are my output

3

1

3C1 = 2C0 + 2C1

2C0 = 1

2C1 = 1C0 + 1C1

1C0 = 1

1C1 = 1

2C1 = 2

3C1 = 2 (correct answer should be "3C1 = 3")

How should I mofify it?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!