I need to compute combinatorials (nCr) in Python but cannot find the function to do that in math, numpy or stat libraries. Something
math
numpy
stat
This function is very optimazed.
def nCk(n,k): m=0 if k==0: m=1 if k==1: m=n if k>=2: num,dem,op1,op2=1,1,k,n while(op1>=1): num*=op2 dem*=op1 op1-=1 op2-=1 m=num//dem return m