I tried using this relationship to recursively find the value of nCr:
nCr = (n - r + 1) / r * nC(r-1)
int comb(int n, int r){
if(r == 0) return 1;
return ((n - r + 1) / r) * comb(n , r - 1);
}
For a call of 6C2 I get 12 instead of 15. I have tried to trace, but I'm getting the right answer. Any input is appreciated! Thank you