What I'm basically looking for is described in the title. Here are some examples of what the function I'm looking for should do. Is there an existing function that does this? Even if not, are there similar functions? Thanks in advance!
ex) f(4,2) = n(n-1)+n(n-2)+n(n-3)+(n-1)(n-2)+(n-1)(n-3)+(n-2)(n-3)
f(4,3) = n(n-1)(n-2)+n(n-1)(n-3)+n(n-2)(n-3)+(n-1)(n-2)(n-3)
f(4,4) = n(n-1)(n-2)(n-3)
f(4,1) = n+(n-1)+(n-2)+(n-3)
f(4,0) = 1