n = int(input())
if n==2:
print(1)
else:
ans = 1;
for i in range (2,n+1):
ans = ans*(n+i)/i
print(int(ans))
n = int(input())
if n==2:
print(1)
else:
ans = 1;
for i in range (2,n+1):
ans = ans*(n+i)/i
print(int(ans))
@kunaljindal you program will fail for every odd number as then n+2 will be odd and dividing by 2 will lead to loss in data.
For using this formula you can use two variable to store the demon and numerator separately, or you can use dp/recursion or you do one thing modify the expression to:
for i in range (2,n+1):
ans = (ans*(2*n+2-i))/i
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.