?
What is the output of the following code in python, if the input is given as 8?
What is the output of the following code in python, if the input is given as 8?
def CatalanNumber(n):
if n<= 1 :
return 1
result=0
for x in range(n):
result = result + CatalanNumber(x) * CatalanNumber(n-x-1)
return result
n=int(input("Enter the number:"))
answer=CatalanNumber(n)
print(" ", answer)
def CatalanNumber(n):
if n<= 1 :
return 1
result=0
for x in range(n):
result = result + CatalanNumber(x) * CatalanNumber(n-x-1)
return result
n=int(input("Enter the number:"))
answer=CatalanNumber(n)
print(" ", answer)
Join the Discussion
Login to post a comment or share your explanation.
Login