Is there a function of, say, x and y that would take the first x factors in a factorial and return a xCy amounts of terms with y factors in each term?

36 Views Asked by At

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