calculating Nck values using dp
Python
l=[[]]
def nck(n,k):
if(k==0 or n==k):
l[n][k]=1
return l[n][k]
if(l[n][k]):
return l[n][k]
l[n][k]=nck((n-1),(k-1))+nck((n-1),k)
return l[n][k]
n,k=map(int,input().split())
for i in range(n+1):
l.append([0 for j in range(k+1)])
nck(n,k)
print(l[n][k])
Output
Embed on website
To embed this program on your website, copy the following code and paste it into your website's HTML:
Comments
This comment belongs to a banned user and is only visible to admins.
This comment belongs to a deleted user and is only visible to admins.