I am looking for a c++ or c version of a function that will implement N choose M.


i.e. set A= {a,b,c,d)
N=4
M=2

4 choose 2 from set A I get 6 total combos = N!/M!*(N-M)!

ab
ac
ad
bc
bd
cd


I tried to develop it using recursion, but I just don't see it.

Any help or pointers would be very helpful.