fork download
  1. #include <stdio.h>
  2.  
  3. int combi(int n, int r){
  4. if (r == 0)
  5. return 1;
  6. else if(n == r)
  7. return 1;
  8. else if (r == 1)
  9. return n;
  10. else
  11. return combi(n - 1, r - 1) + combi(n - 1, r);
  12. }
  13. int main(void){
  14. int n, r;
  15. n = 4, r = 2;
  16. printf("C(n=%d, r=%d) = %d\n", n, r, combi(n, r));
  17. return 0;
  18. }
  19.  
  20.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
C(n=4, r=2) = 6